本文整理汇总了Python中util.jsonpify函数的典型用法代码示例。如果您正苦于以下问题:Python jsonpify函数的具体用法?Python jsonpify怎么用?Python jsonpify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了jsonpify函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: add_blob_content
def add_blob_content():
response_object = {
'status': 'success',
'now': datetime.utcnow().isoformat(),
'filelink': None,
}
folder = Folder.retrieve_by_id(3001)
if not folder:
response_object['status'] = 'failure'
return util.jsonpify(response_object)
upload_files = get_uploads(flask.request, 'file')
if len(upload_files):
blob_info = upload_files[0]
if blob_info.size:
f = File.create(
blob_info.key(),
size=blob_info.size,
filename=os.path.basename(blob_info.filename.replace('\\','/')),
content_type=blob_info.content_type)
f.put()
if f.get_cached_url():
folder.files.append(f.key)
folder.put()
response_object['filelink'] = f.get_cached_url()
else:
blob_info.delete()
return util.jsonpify(response_object)
开发者ID:aegoroff,项目名称:egoroff.spb.ru,代码行数:29,代码来源:views.py
示例2: make_response
def make_response(data, marshal_table, cursors=None):
if util.is_iterable(data):
response = {
'status': 'success',
'count': len(data),
'now': datetime.utcnow().isoformat(),
'result': map(lambda l: flask_restful.marshal(l, marshal_table), data),
}
if cursors:
if isinstance(cursors, dict):
if cursors.get('next'):
response['next_cursor'] = cursors['next']
response['next_url'] = util.generate_next_url(cursors['next'])
if cursors.get('prev'):
response['prev_cursor'] = cursors['prev']
response['prev_url'] = util.generate_next_url(cursors['prev'])
else:
response['next_cursor'] = cursors
response['next_url'] = util.generate_next_url(cursors)
return util.jsonpify(response)
return util.jsonpify({
'status': 'success',
'now': datetime.utcnow().isoformat(),
'result': flask_restful.marshal(data, marshal_table),
})
开发者ID:stretchhog,项目名称:prfit,代码行数:25,代码来源:helpers.py
示例3: handle_error
def handle_error(e):
if not e:
e = {}
else:
logging.exception(e)
try:
e.code
except AttributeError:
e.code = 500
e.name = e.description = 'Internal Server Error'
result = {
'status': 'error',
'error_code': e.code,
'error_name': util.slugify(e.name),
'error_message': e.name,
'error_class': e.__class__.__name__,
'description': e.description,
'data': None,
'validations': None
}
if hasattr(e, 'data'):
result['data'] = e.data
if hasattr(e, 'validations'):
result['validations'] = e.validations
return util.jsonpify(result), e.code
开发者ID:tiberiucorbu,项目名称:av-website,代码行数:26,代码来源:helpers.py
示例4: error_handler
def error_handler(e):
try:
e.code
except:
class e(object):
code = 500
name = "Internal Server Error"
if flask.request.path.startswith("/_s/"):
return (
util.jsonpify(
{
"status": "error",
"error_code": e.code,
"error_name": e.name.lower().replace(" ", "_"),
"error_message": e.name,
}
),
e.code,
)
return (
flask.render_template(
"error.html", title="Error %d (%s)!!1" % (e.code, e.name), html_class="error-page", error=e
),
e.code,
)
开发者ID:handol,项目名称:gae-init,代码行数:28,代码来源:main.py
示例5: error_handler
def error_handler(e):
logging.exception(e)
try:
e.code
except AttributeError:
e.code = 500
e.name = "Internal Server Error"
if flask.request.path.startswith("/_s/"):
return (
util.jsonpify(
{
"status": "error",
"error_code": e.code,
"error_name": util.slugify(e.name),
"error_message": e.name,
"error_class": e.__class__.__name__,
}
),
e.code,
)
return (
flask.render_template(
"error.html", title="Error %d (%s)!!1" % (e.code, e.name), html_class="error-page", error=e
),
e.code,
)
开发者ID:JackNova,项目名称:gae-init,代码行数:28,代码来源:main.py
示例6: make_response
def make_response(data, marshal_table, next_cursor=None):
if util.is_iterable(data):
response = {
'status': 'success',
'count': len(data),
'now': datetime.utcnow().isoformat(),
'result': map(lambda l: restful.marshal(l, marshal_table), data),
}
if next_cursor:
response['next_cursor'] = next_cursor
response['next_url'] = util.generate_next_url(next_cursor)
return util.jsonpify(response)
return util.jsonpify({
'status': 'success',
'now': datetime.utcnow().isoformat(),
'result': restful.marshal(data, marshal_table),
})
开发者ID:84cs,项目名称:gae-init-upload,代码行数:17,代码来源:helpers.py
示例7: get
def get(self):
parser = reqparse.RequestParser()
parser.add_argument('hub.mode')
parser.add_argument('hub.challenge')
parser.add_argument('hub.verify_token')
args = parser.parse_args()
logging.debug(args)
if args['hub.mode'] == 'subscribe':
if args['hub.verify_token'] == config.FACEBOOK_WEBHOOK_VERIFY_TOKEN:
return int(args['hub.challenge'])
result = {}
return util.jsonpify(result)
开发者ID:nazroll,项目名称:noobotkit,代码行数:14,代码来源:facebook.py
示例8: handle_error
def handle_error(e):
logging.exception(e)
try:
e.code
except AttributeError:
e.code = 500
e.name = e.description = 'Internal Server Error'
return util.jsonpify({
'status': 'error',
'error_code': e.code,
'error_name': util.slugify(e.name),
'error_message': e.name,
'error_class': e.__class__.__name__,
'description': e.description,
}), e.code
开发者ID:stretchhog,项目名称:prfit,代码行数:15,代码来源:helpers.py
示例9: error_handler
def error_handler(e):
try:
e.code
except AttributeError as e:
e.code = 500
e.name = 'Internal Server Error'
if flask.request.path.startswith('/_s/'):
return util.jsonpify({
'status': 'error',
'error_code': e.code,
'error_name': e.name.lower().replace(' ', '_'),
'error_message': e.name,
}), e.code
return flask.render_template(
'error.html',
title='Error %d (%s)!!1' % (e.code, e.name),
html_class='error-page',
error=e,
), e.code
开发者ID:Eenvincible,项目名称:gae-init,代码行数:21,代码来源:main.py
示例10: error_handler
def error_handler(e):
logging.exception(e)
try:
e.code
except AttributeError:
e.code = 500
e.name = 'Internal Server Error'
if flask.request.path.startswith('/_s/'):
return util.jsonpify({
'status': 'error',
'error_code': e.code,
'error_name': util.slugify(e.name),
'error_message': e.name,
'error_class': e.__class__.__name__,
}), e.code
return flask.render_template(
'error.html',
title='Error %d (%s)!!1' % (e.code, e.name),
html_class='error-page',
error=e,
), e.code
开发者ID:georgekis,项目名称:gae-init-docs,代码行数:23,代码来源:main.py
示例11: make_object_response
def make_object_response(obj):
return util.jsonpify({
'status': 'success',
'now': datetime.utcnow().isoformat(),
'result': obj
})
开发者ID:tiberiucorbu,项目名称:av-website,代码行数:6,代码来源:helpers.py
示例12: post
#.........这里部分代码省略.........
logging.debug(
'"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
'incoming',
fb_timestamp,
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
attachment['type'],
attachment['payload'],
fb_seq,
fb_mid
)
)
else:
logging.debug(
'"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
'incoming',
fb_timestamp,
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
attachment['type'],
attachment['payload'],
fb_seq,
fb_mid
)
)
else:
logging.debug(
'"%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
'incoming',
fb_timestamp,
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
'text',
fb_content['text'],
fb_seq,
fb_mid
)
)
if 'show example text' in fb_content['text']:
example_message_text(
fb_sender,
'This is an example of a message with text only.'
)
example_message_text(
fb_sender,
'The last thing you said was: "%s"' % fb_content['text']
)
if 'show example image' in fb_content['text']:
example_message_text(
fb_sender,
'This is an example of a message with an image only.'
)
example_message_image(
fb_sender,
'http://petersapparel.parseapp.com/img/item100-thumb.png'
)
elif 'delivery' in fb_obj:
fb_delivery = fb_obj['delivery']
fb_watermark = fb_delivery['watermark']
fb_seq = fb_delivery['seq']
if 'mids' in fb_delivery and len(fb_delivery['mids']) > 0:
for fb_mid in fb_delivery['mids']:
logging.debug(
'"%s" "%s" "%s" "%s" "%s" "%s" "%s"' % (
'delivery',
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
fb_watermark,
fb_seq,
fb_mid
)
)
else:
logging.debug(
'"%s" "%s" "%s" "%s" "%s" "%s"' % (
'delivery',
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
fb_watermark,
fb_seq
)
)
else:
logging.debug(
'"%s" "%s" "%s" "%s" "%s"' % (
'incoming',
fb_page_id,
fb_sender['id'],
fb_recipient['id'],
fb_obj,
)
)
result = {}
return util.jsonpify(result)
开发者ID:nazroll,项目名称:noobotkit,代码行数:101,代码来源:facebook.py
注:本文中的util.jsonpify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论