本文整理汇总了Python中gluon.URL属性的典型用法代码示例。如果您正苦于以下问题:Python gluon.URL属性的具体用法?Python gluon.URL怎么用?Python gluon.URL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gluon
的用法示例。
在下文中一共展示了gluon.URL属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: index
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def index():
"""
Edit/Show package content
"""
pkg_item = application.getItemByUUID(request.args(0))
content = db.plugin_package_content(item_id=pkg_item.unique_id)
form = SQLFORM(
db.plugin_package_content,
record=content,
showid=False)
if form.process().accepted:
application.indexItem(pkg_item.unique_id)
redirect(URL('default', 'index'))
return locals()
示例2: process
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def process(self):
"""
$ curl http://127.0.0.1:8000/collection/default/api
$ curl http://127.0.0.1:8000/collection/default/api/book
$ curl http://127.0.0.1:8000/collection/default/api/book?page=1&per_page=20
$ curl http://127.0.0.1:8000/collection/default/api/book?search=title contains "the"
$ curl http://127.0.0.1:8000/collection/default/api/bookcase
$ curl http://127.0.0.1:8000/collection/default/api/bookcase/1
$ curl -X POST -d 'title=GEB' http://127.0.0.1:8000/collection/default/api/book
{"row": {"id": 91}}
$ curl -X DELETE http://127.0.0.1:8000/collection/default/api/book/93
{"count": 1}
$ curl -X DELETE http://127.0.0.1:8000/collection/default/api/book/93
{"count": 0}
"""
# this is the only part web2py specific!
from gluon import URL, current
request, response = current.request, current.response
res = self.handle_request(URL(), request.env.request_method,
request.args(0), request.args(1), request.vars)
if 'status' in res and res['status'] != 200:
response.status = res['status']
response.headers['Content-Type'] = 'application/json'
return response.json(res, indent=2)+'\n'
示例3: __init__
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def __init__(self,
pk, sk,
amount, # in cents
description,
currency = 'usd',
currency_symbol = '$',
security_notice = True,
disclosure_notice = True,
template = None):
from gluon import current, redirect, URL
if not (current.request.is_local or current.request.is_https):
redirect(URL(args=current.request.args,scheme='https'))
self.pk = pk
self.sk = sk
self.amount = amount
self.description = description
self.currency = currency
self.currency_symbol = currency_symbol
self.security_notice = security_notice
self.disclosure_notice = disclosure_notice
self.template = template or TEMPLATE
self.accepted = None
self.errors = None
self.signature = sha1(repr((self.amount,self.description))).hexdigest()
示例4: error
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def error(self,code="400", title="BAD REQUEST", message="UNKNOWN", form_errors={}):
request, response = self.request, self.response
r = OrderedDict({
"version" : self.VERSION,
"href" : URL(args=request.args,vars=request.vars),
"error" : {
"title" : title,
"code" : code,
"message" : message}})
if self.extensions and form_errors:
# https://github.com/collection-json/extensions/blob/master/errors.md
r['errors'] = errors = {}
for key, value in form_errors.items():
errors[key] = {'title':'Validation Error','code':'','message':value}
response.headers['Content-Type'] = 'application/vnd.collection+json'
response.status = 400
return response.json({'collection':r})
示例5: __init__
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def __init__(self, g=None, # g for backward compatibility ###
urlbase="https://web2py.com/cas/cas",
actions=['login', 'validate', 'logout'],
maps=dict(username=lambda v: v.get('username', v['user']),
email=lambda v: v.get('email', None),
user_id=lambda v: v['user']),
casversion=1,
casusername='cas:user'
):
self.urlbase = urlbase
self.cas_login_url = "%s/%s" % (self.urlbase, actions[0])
self.cas_check_url = "%s/%s" % (self.urlbase, actions[1])
self.cas_logout_url = "%s/%s" % (self.urlbase, actions[2])
self.maps = maps
self.casversion = casversion
self.casusername = casusername
# vars commented because of
# https://code.google.com/p/web2py/issues/detail?id=1774
self.cas_my_url = URL(args=current.request.args,
#vars=current.request.vars,
scheme=True)
示例6: login_url
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def login_url(self, next="/"):
d = saml2_handler(current.session, current.request)
if 'url' in d:
redirect(d['url'])
elif 'error' in d:
current.session.flash = d['error']
redirect(URL('default','index'))
elif 'response' in d:
# a['assertions'][0]['attribute_statement'][0]['attribute']
# is list of
# {'name': 'http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname', 'name_format': None, 'text': None, 'friendly_name': None, 'attribute_value': [{'text': 'CAA\\dev-mdp', 'extension_attributes': "{'{http://www.w3.org/2001/XMLSchema-instance}type': 'xs:string'}", 'extension_elements': []}], 'extension_elements': [], 'extension_attributes': '{}'}
try:
attributes = d['response'].assertions[0].attribute_statement[0].attribute
except:
attributes = d['response'].assertion.attribute_statement[0].attribute
current.session.saml2_info = dict(
(a.name, [i.text for i in a.attribute_value]) for a in attributes)
return next
示例7: __init__
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def __init__(self, g=None, # g for backward compatibility ###
urlbase="https://web2py.com/cas/cas",
actions=['login', 'validate', 'logout'],
maps=dict(username=lambda v: v.get('username', v['user']),
email=lambda v: v.get('email', None),
user_id=lambda v: v['user']),
casversion=1,
casusername='cas:user'
):
self.urlbase = urlbase
self.cas_login_url = "%s/%s" % (self.urlbase, actions[0])
self.cas_check_url = "%s/%s" % (self.urlbase, actions[1])
self.cas_logout_url = "%s/%s" % (self.urlbase, actions[2])
self.maps = maps
self.casversion = casversion
self.casusername = casusername
# vars commented because of
# https://code.google.com/p/web2py/issues/detail?id=1774
self.cas_my_url = URL(args=current.request.args,
#vars=current.request.vars,
scheme=True)
示例8: error
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def error(self,code="400", title="BAD REQUEST", message="UNKNOWN", form_errors={}):
request, response = self.request, self.response
r = OrderedDict({
"version" : self.VERSION,
"href" : URL(args=request.args,vars=request.vars),
"error" : {
"title" : title,
"code" : code,
"message" : message}})
if self.extensions and form_errors:
# https://github.com/collection-json/extensions/blob/master/errors.md
r['errors'] = errors = {}
for key, value in form_errors.items():
errors[key] = {'title':'Validation Error','code':'','message':value}
response.headers['Content-Type'] = 'application/vnd.collection+json'
response.status = 400
return response.json({'collection':r})
示例9: getItemURL
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def getItemURL(self, unique_id):
item = self.getItemByUUID(unique_id)
c = "plugin_{}".format(item.item_type)
f = "index.html"
return URL(c=c, f=f, args=[item.unique_id])
示例10: getContentChangesURL
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def getContentChangesURL(self, unique_id):
item = self.getItemByUUID(unique_id)
c = "plugin_{}".format(item.item_type)
f = "changelog.html"
return URL(c=c, f=f, args=[item.unique_id])
示例11: export
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def export(self, item, export_dir):
"""
Export picture content to export_dir
"""
# put the picture general info
db = self.db
pic_info = db.plugin_picture_info(item_id=item.unique_id)
with open(os.path.join(export_dir, 'picture.json'), 'w') as f:
f.write(pic_info.as_json())
for r_id in pic_info.renditions:
# for eatch rendition put the descriptive info and the image
rend = db.plugin_picture_rendition(r_id)
rend_dir = os.path.join(export_dir, str(r_id))
os.mkdir(rend_dir)
with open(os.path.join(rend_dir, 'rendition.json'), 'w') as f:
f.write(json.dumps({
'picture': URL(
'default', 'download', args=[rend.picture],
scheme=True, host=True),
'purpose': rend.purpose,
'height': rend.height,
'width': rend.width,
'color': rend.color,
'format': rend.format
}))
# done
return
示例12: get_item_url
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def get_item_url(self, item):
return URL('plugin_picture', 'index.html', args=[item.unique_id])
示例13: get_changelog_url
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def get_changelog_url(self, item):
return URL('plugin_picture', 'changelog', args=[item.unique_id])
示例14: get_item_url
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def get_item_url(self, item):
return URL('plugin_photoset', 'index.html', args=[item.unique_id])
示例15: get_changelog_url
# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import URL [as 别名]
def get_changelog_url(self, item):
return URL('plugin_photoset', 'changelog', args=[item.unique_id])