本文整理汇总了Python中models.Config.query方法的典型用法代码示例。如果您正苦于以下问题:Python Config.query方法的具体用法?Python Config.query怎么用?Python Config.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Config
的用法示例。
在下文中一共展示了Config.query方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_instagram
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def load_instagram():
access_token = Config.query(Config.name == 'instagram_access_token').order(-Config.date_added).get()
if access_token is None:
return Response(json.dumps({ 'error': 'instagram_access_token configuration was not found.' }), status=500, mimetype='application/json');
client_secret = Config.query(Config.name == 'instagram_client_secret').order(-Config.date_added).get()
if client_secret is None:
return Response(json.dumps({ 'error': 'instagram_client_secret configuration was not found.' }), status=500, mimetype='application/json');
return instagram_import.import_media(access_token.value, client_secret.value)
示例2: load_tracker
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def load_tracker():
tracker_url = Config.query(Config.name == 'tracker_url').order(-Config.date_added).get()
if tracker_url is None:
return Response(json.dumps({ 'error': 'tracker_url configuration was not found.' }), status=500, mimetype='application/json');
tracker_type = Config.query(Config.name == 'tracker_type').order(-Config.date_added).get()
if tracker_type is None:
return Response(json.dumps({ 'error': 'tracker_type configuration was not found.' }), status=500, mimetype='application/json');
if tracker_type.value == 'delorme':
return delorme.load_data(tracker_url.value)
elif tracker_type.value == 'spot':
return Response(json.dumps({ 'error': 'tracker not supported.' }), status=400, mimetype='application/json');
else:
return Response(json.dumps({ 'error': 'tracker not supported.' }), status=400, mimetype='application/json');
示例3: is_open_or_close
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def is_open_or_close():
c = Config.query().get()
if not c:
c = Config()
c.is_open = False
c.put()
return False
return c.is_open
示例4: get_auth_secret
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def get_auth_secret():
"""
Returns the secret required to update the click counter configuration.
If no secret is configured, a random secret is generated and persisted.
"""
from models import Config
secret_config = Config.query(Config.key == "auth_secret").get()
if not secret_config:
secret_config = set_auth_secret(''.join(random.choice(string.lowercase) for i in range(10)))
return secret_config.value
示例5: load_flickr
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def load_flickr():
user_id = Config.query(Config.name == 'flickr_username').order(-Config.date_added).get()
if user_id is None:
return Response(json.dumps({ 'error': 'flickr_username configuration was not found.' }), status=500, mimetype='application/json');
photoset_id = Config.query(Config.name == 'flickr_photoset_title').order(-Config.date_added).get()
if photoset_id is None:
return Response(json.dumps({ 'error': 'flickr_photoset_title configuration was not found.' }), status=500, mimetype='application/json');
api_key = Config.query(Config.name == 'flickr_api_key').order(-Config.date_added).get()
if api_key is None:
return Response(json.dumps({ 'error': 'flickr_api_key configuration was not found.' }), status=500, mimetype='application/json');
api_secret = Config.query(Config.name == 'flickr_api_secret').order(-Config.date_added).get()
if api_secret is None:
return Response(json.dumps({ 'error': 'flickr_api_secret configuration was not found.' }), status=500, mimetype='application/json');
return flickr.import_photos(user_id.value, photoset_id.value, api_key.value, api_secret.value)
示例6: sendMailResult
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def sendMailResult():
# TODO: test this
message = mail.EmailMessage(sender="MercatoLibero <[email protected]>",
subject="Risultati")
users = User.query().fetch()
to = ""
for user in users:
to += user.email + ";"
message.to = to
calls_open = Call.query(Call.status == "OPEN").fetch()
status = Config.query().get()
if not status:
status = Config()
status.is_open = True
status.put()
if len(calls_open) > 0:
path = os.path.join(os.path.dirname(__file__), 'templates', 'mail_results.html')
params = dict(open=[e.to_dict() for e in calls_open])
res = template.render(path, params)
for o in calls_open:
o.status = "CLOSED"
o.put()
message.html = res
message.send()
示例7: get_config
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def get_config(name):
config = Config.query(Config.name == name).order(-Config.date_added).get()
if config is not None:
return Response(json.dumps(config.to_dict()), mimetype='application/json');
else:
return Response(json.dumps({ 'error': 'configuration was not found.' }), status=400, mimetype='application/json');
示例8: get
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def get(self):
status = Config.query().get()
if not status:
status = Config()
status.is_open = False
status.put()
示例9: set_open_or_closed
# 需要导入模块: from models import Config [as 别名]
# 或者: from models.Config import query [as 别名]
def set_open_or_closed(v):
c = Config.query().get()
if not c:
c = Config()
c.is_open = v
c.put()