本文整理汇总了Python中models.Client.gen_id方法的典型用法代码示例。如果您正苦于以下问题:Python Client.gen_id方法的具体用法?Python Client.gen_id怎么用?Python Client.gen_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Client
的用法示例。
在下文中一共展示了Client.gen_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: app_add_post
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import gen_id [as 别名]
def app_add_post():
"""
创建应用
"""
db = g._db
store_id = session['user']['store_id']
name = request.form.get('name')
key = random_ascii_string(32)
secret = random_ascii_string(32)
android, ios = _get_clients()
developer_id = 0
db.begin()
appid = App.gen_id(db)
App.create_app(db, appid, name, developer_id, key, secret, store_id)
if android:
push_types = request.form.getlist('push_type')
xinge_access_id = request.form.get('xinge_access_id', '')
xinge_secret_key = request.form.get('xinge_secret_key', '')
mi_appid = request.form.get('mi_appid', '')
mi_secret_key = request.form.get('mi_secret_key', '')
hw_appid = request.form.get('hw_appid', '')
hw_secret_key = request.form.get('hw_secret_key', '')
gcm_sender_id = request.form.get('gcm_sender_id', '')
gcm_api_key = request.form.get('gcm_api_key', '')
client_id = Client.gen_id(db)
Client.create_client(db, client_id, appid, developer_id, PlatformType.ANDROID, android['platform_identity'])
Client.create_android(db, client_id, xinge_access_id, xinge_secret_key, mi_appid, mi_secret_key, hw_appid, hw_secret_key, gcm_sender_id, gcm_api_key)
if ios:
sandbox_key_file = request.files.get('sandbox_key')
if sandbox_key_file:
filename = sandbox_key_file.filename
ext = os.path.splitext(filename)[1]
if ext == '.p12':
sandbox_key = sandbox_key_file.read()
sandbox_key_secret = request.form.get('sandbox_key_secret')
else:
sandbox_key = ""
sandbox_key_secret = ""
else:
sandbox_key = ""
sandbox_key_secret = ""
production_key_file = request.files.get('production_key')
if production_key_file:
filename = production_key_file.filename
ext = os.path.splitext(filename)[1]
if ext == '.p12':
production_key = production_key_file.read()
production_key_secret = request.form.get('production_key_secret')
else:
production_key = ""
production_key_secret = ""
else:
production_key = ""
production_key_secret = ""
client_id = Client.gen_id(db)
Client.create_client(db, client_id, appid, developer_id, PlatformType.IOS, ios['platform_identity'])
Client.create_ios(db, client_id, sandbox_key, sandbox_key_secret, production_key, production_key_secret)
db.commit()
return redirect(url_for('.app_complete', app_id=appid))
示例2: app_edit_post
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import gen_id [as 别名]
def app_edit_post(appid):
"""
修改应用
"""
db = g._db
android, ios = _get_clients()
developer_id = 0
if android:
push_types = request.form.getlist('push_type')
xinge_access_id = request.form.get('xinge_access_id', '')
xinge_secret_key = request.form.get('xinge_secret_key', '')
mi_appid = request.form.get('mi_appid', '')
mi_secret_key = request.form.get('mi_secret_key', '')
hw_appid = request.form.get('hw_appid', '')
hw_secret_key = request.form.get('hw_secret_key', '')
gcm_sender_id = request.form.get('gcm_sender_id', '')
gcm_api_key = request.form.get('gcm_api_key', '')
c = Client.get_android(db, appid)
if not c:
client_id = Client.gen_id(db)
Client.create_client(db, client_id, appid, developer_id, PlatformType.ANDROID, android['platform_identity'])
Client.create_android(db, client_id, xinge_access_id, xinge_secret_key, mi_appid, mi_secret_key, hw_appid, hw_secret_key, gcm_sender_id, gcm_api_key)
else:
Client.update_android(db, c['id'], xinge_access_id, xinge_secret_key, mi_appid, mi_secret_key, hw_appid, hw_secret_key, gcm_sender_id, gcm_api_key)
if ios:
sandbox_key_file = request.files.get('sandbox_key')
if sandbox_key_file:
filename = sandbox_key_file.filename
ext = os.path.splitext(filename)[1]
if ext == '.p12':
sandbox_key = sandbox_key_file.read()
sandbox_key_secret = request.form.get('sandbox_key_secret')
else:
sandbox_key = ""
sandbox_key_secret = ""
else:
sandbox_key = ""
sandbox_key_secret = ""
production_key_file = request.files.get('production_key')
if production_key_file:
filename = production_key_file.filename
ext = os.path.splitext(filename)[1]
if ext == '.p12':
production_key = production_key_file.read()
production_key_secret = request.form.get('production_key_secret')
else:
production_key = ""
production_key_secret = ""
else:
production_key = ""
production_key_secret = ""
c = Client.get_ios(db, appid)
if not c:
client_id = Client.gen_id(db)
Client.create_client(db, client_id, appid, developer_id, PlatformType.IOS, ios['platform_identity'])
Client.create_ios(db, client_id, sandbox_key, sandbox_key_secret, production_key, production_key_secret)
else:
Client.update_ios(db, c['id'], sandbox_key, sandbox_key_secret, production_key, production_key_secret)
return redirect(url_for('.app_detail', appid=appid))