本文整理汇总了Python中models.Client.put方法的典型用法代码示例。如果您正苦于以下问题:Python Client.put方法的具体用法?Python Client.put怎么用?Python Client.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Client
的用法示例。
在下文中一共展示了Client.put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_one_report
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client 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)
示例2: populate_datastore
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def populate_datastore():
client_key_name1='client01'
client1 = Client(key_name=client_key_name1, id='12345678', name='Organic Oranges LLC', domain=db.Link("http://client1.clickin-tech.appspot.com"))
client1.put()
client_key_name2='client02'
client2 = Client(key_name=client_key_name2, id='87654321', name='Green Trees Inc.', domain=db.Link("http://client2.clickin-tech.appspot.com"))
client2.put()
admin_key_name1='admin001'
admin1 = Client_User(key_name=admin_key_name1, client=client1, id='001002', name='Daniel Alves',
email='[email protected]')
admin1.put()
admin_key_name2='admin002'
admin2 = Client_User(key_name=admin_key_name2, client=client1, id='001005', name='Andres Iniesta',
email='[email protected]')
admin2.put()
admin_key_name5='admin05'
admin5 = Client_User(key_name=admin_key_name5, client=client2, id='0010011', name='Josep Guardiola',
email='[email protected]')
admin5.put()
admin_key_name6='admin06'
admin6 = Client_User(key_name=admin_key_name6, client=client2, id='0010016', name='Lionel Messi',
email='[email protected]')
admin6.put()
#ClickIn People Search
app_key_name1='app1'
app1 = App(key_name=app_key_name1, client=client1, app_id='163185560402939',
api_key='807c2277abe596cfe542927858105306',
app_secret='aae6abb4d6bf0b41f066c387ab36e486',
name = 'ClickIn People Search',
domain=db.Link("http://app1.client1.clickin-tech.appspot.com/"))
app1.put()
#Click In People Search 2
app_key_name2='app2'
app2 = App(key_name=app_key_name2, client=client1, app_id='114549068628127',
api_key='7f15ffb2b72ff6c4a6d08daebca21a52',
app_secret='61545bcd8a3d9fc6a8107eaed5cbe4de',
name = 'ClickIn People Search 2',
domain=db.Link("http://app2.client1.clickin-tech.appspot.com/"))
app2.put()
#Cool Running App
app_key_name3='app3'
app3 = App(key_name=app_key_name3, client=client2, app_id='107411582680918',
api_key='7a55f39fb4e0371aad78e1bd8dd517af',
app_secret='c12b89b5f815cebe27636cd8c50a6264',
name = 'Cool Running App',
domain=db.Link("http://app1.client2.clickin-tech.appspot.com/"))
app3.put()
示例3: verify
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def verify(request):
client_id = request.headers.get('X-AEFS-ClientId', None)
signature = request.headers.get('X-AEFS-Signature', None)
body = request.body
if client_id and signature:
client = Client.get_by_key_name(client_id)
if not client:
client = Client(key_name=client_id)
h = hmac.new(config.shared_secret, client_id + str(client.nonce) + body, hashlib.sha1)
client.new_nonce()
client.put()
return h.hexdigest() == signature
else:
return False
示例4: register
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def register(self):
"""Registers a new client (app)."""
if request.method == u'POST':
client_key = self.generate_client_key()
secret = self.generate_client_secret()
name = request.form.get(u"name")
description = request.form.get(u"description")
callback = request.form.get(u"callback")
pubkey = request.form.get(u"pubkey")
# Validoitaan syötteet:
params = [name, description, callback, pubkey]
if any(not param for param in params):
flash("Please fill all fields.")
return redirect(url_for("register"))
for param in params:
if len(param) < 5:
flash("Input too short: " + param)
return redirect(url_for("register"))
if len(param) > 60:
flash("Input too long: ")
return redirect(url_for("register"))
if not callback.startswith("http://"):
flash("Invalid callback url: " + callback)
return redirect(url_for("register"))
info = {
u"client_key": client_key,
u"name": name,
u"description": description,
u"secret": secret,
u"pubkey": pubkey
}
cb = Callback(callback=callback)
cb_key = cb.put()
client = Client(**info)
client.callbacks.append(cb_key)
client.resource_owner = g.user.key
client.put()
return render_template(u"client.html", **info)
else:
clients = Client.query(Client.resource_owner == g.user.key)
return render_template(u"register.html", clients=clients)
示例5: start_oauth2_dance
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def start_oauth2_dance(self):
login_hint = ''
scope = ''
client = Client.get_by_id(1)
if not client:
# If client does not exist then create an empty one
client = Client(id=1)
client.installer_user = users.get_current_user().email()
client.put()
# Get the login hint from configuration
approval_prompt = 'auto' if client.refresh_token else 'force'
scope = constants.OAUTH2_SCOPE
redirect_uri = helpers.url_for('oauth.oauth_callback',
_external=True)
oauth_helper = OAuthDanceHelper(redirect_uri, approval_prompt, scope)
url = oauth_helper.step1_get_authorize_url()
#TODO: Add a random token to avoid forgery
return redirect(url)
示例6: start_oauth2_dance
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def start_oauth2_dance():
login_hint = ""
scope = ""
client = Client.get_by_id(1)
if not client:
# If client does not exist then create an empty one
client = Client(id=1)
client.put()
# Get the login hint from configuration
# approval_prompt = 'auto' if client.reseller_refresh_token else 'force'
# Always force to be sure to get valid refresh token
approval_prompt = "force"
login_hint = get_setting("OAUTH2_RESELLER_DOMAIN_USER")
scope = get_setting("OAUTH2_SCOPE")
redirect_uri = helpers.url_for("oauth_callback", _external=True)
oauth_helper = OAuthDanceHelper(scope=scope, redirect_uri=redirect_uri, approval_prompt=approval_prompt)
url = oauth_helper.step1_get_authorize_url()
# TODO: Add a random token to avoid forgery
return redirect("%s&login_hint=%s" % (url, login_hint))
示例7: saveNew
# 需要导入模块: from models import Client [as 别名]
# 或者: from models.Client import put [as 别名]
def saveNew(request):
client = Client()
client = ClientService.setClientProperties(client, request)
client.put()
time.sleep(sleepTime)