Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Sync#38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
TommyLemon merged 4 commits intoAPIJSON:masterfromzhangchunlin:master
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletionsuliweb_apijson/apijson/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
#coding=utf-8

from uliweb import settings, models, request, functions
from uliweb import settings, models, request, functions, UliwebError
from uliweb.orm import ModelNotFound
import logging

log = logging.getLogger('apijson')

def get_apijson_tables(role="UNKNOWN"):
from uliweb import settings
Expand DownExpand Up@@ -82,7 +84,7 @@ def __init__(self,name,params,parent,key):
def _check_GET_permission(self):
GET = self.setting.get("GET")
if not GET:
raise UliwebError("'%s' not accessible by apijson"%(name))
raise UliwebError("'%s' not accessible by apijson"%(self.name))

roles = GET.get("roles")
params_role = self.params.get("@role")
Expand All@@ -93,7 +95,7 @@ def _check_GET_permission(self):
else:
params_role = "UNKNOWN"
if params_role not in roles:
raise UliwebError("'%s' not accessible by role '%s'"%(model_name,params_role))
raise UliwebError("'%s' not accessible by role '%s'"%(self.name,params_role))
if params_role == "UNKNOWN":
self.permission_check_ok = True
elif functions.has_role(request.user,params_role):
Expand Down
5 changes: 3 additions & 2 deletionsuliweb_apijson/apijson/views.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
#coding=utf-8
from uliweb import expose, functions, models, UliwebError
from uliweb.orm import ModelNotFound
from uliweb.utils._compat import string_types
from sqlalchemy.sql import and_, or_, not_
from json import loads
from collections import OrderedDict
Expand DownExpand Up@@ -109,7 +110,7 @@ def _get_one(self,key):
roles = GET.get("roles")
permission_check_ok = False
if not params_role:
if request.user:
ifhasattr(request,"user"):
params_role = "LOGIN"
else:
params_role = "UNKNOWN"
Expand DownExpand Up@@ -224,7 +225,7 @@ def _get_filter_condition(self,model,model_param,item,expr=False):
return self._expr(model,model_param,model_expr=item)
else:
raise UliwebError("item can be array only in @expr: '%s'"%(item))
if not isinstance(item,str):
if not isinstance(item,string_types):
raise UliwebError("item should be array or string: '%s'"%(item))
n = item
if n[0]=="@":
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp