本文整理汇总了Python中models.Report.put方法的典型用法代码示例。如果您正苦于以下问题:Python Report.put方法的具体用法?Python Report.put怎么用?Python Report.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Report
的用法示例。
在下文中一共展示了Report.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reportsv2
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import put [as 别名]
def reportsv2():
if not request.args or not request.args['key'] or request.args['key'] != IOS_API_KEY:
abort(401)
if request.method == "POST":
if not request.json or not 'google_places_id' in request.json or not 'tags' in request.json:
abort(400)
report = Report(
google_places_id=request.json['google_places_id'],
tags=request.json['tags'])
if 'comments' in request.json:
report.populate(comments=request.json['comments'])
if 'ios_device_id' in request.json:
report.populate(ios_device_id=request.json['ios_device_id'])
if 'photo_url' in request.json:
report.populate(photo_url=request.json['photo_url'])
try:
report.put()
return jsonify(report.to_dict())
except CapabilityDisabledError:
abort(400)
if len(request.args) == 1:
reports = Report.query().order(-Report.created_at).fetch(20)
return jsonify({"reports": [report.to_dict() for report in reports]})
if len(request.args) > 2:
abort(400)
if not request.args['google_places_id']:
abort(400)
google_places_id = request.args['google_places_id']
reports = Report.query(Report.google_places_id==google_places_id).order(-Report.created_at).fetch(20)
return jsonify({"reports": [report.to_dict() for report in reports]})
示例2: set_report
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import put [as 别名]
def set_report(name, content):
report = Report.find_by_name(name)
if report is None:
report = Report()
report.name = name
report.content = content
report.put()
示例3: test_one_report
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import put [as 别名]
def test_one_report(self):
client = Client(product=ProductData.killerapp_obj, cookie='123')
client.put()
report = Report(product=ProductData.killerapp_obj, client=client, status=REPORT_NEW, remote_ip='127.0.0.1', data='[]')
report.put()
response = self.get('/status/')
assert 'Queued Reports: 1' in str(response)
示例4: post
# 需要导入模块: from models import Report [as 别名]
# 或者: from models.Report import put [as 别名]
def post(self):
user = users.get_current_user()
if user:
data = json.decode(self.request.body)
# logging.log(logging.INFO, data)
url = data['url']
if url[:3] != 'http':
url = 'http://' + url
report = Report(
author=user,
url=url,
status='SENT'
)
key = report.put()
deferred.defer(parsepage, key, _countdown=30, _queue="parsequeue")
result = {
'result': JSONEncoder().encode(key.get()),
}
self.response.headers['Content-Type'] = 'application/json'
self.response.write(json.encode(result))