本文整理汇总了Python中models.Account.set_hash_and_key方法的典型用法代码示例。如果您正苦于以下问题:Python Account.set_hash_and_key方法的具体用法?Python Account.set_hash_and_key怎么用?Python Account.set_hash_and_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.set_hash_and_key方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_placeholder
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import set_hash_and_key [as 别名]
def test_placeholder(self):
user = users.User("[email protected]")
account = Account(user=user)
account.set_hash_and_key()
account.put()
self.assertTrue(account.user.email() == "[email protected]")
示例2: RequestHandler
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import set_hash_and_key [as 别名]
class RequestHandler(webapp.RequestHandler):
def initialize(self, request, response):
super(RequestHandler, self).initialize(request, response)
self.user = users.get_current_user()
if self.user:
self.login_url = None
self.logout_url = users.create_logout_url("/")
self.account = Account.all().filter("user =", self.user).get()
if not self.account:
# Set up a Notify.io account
self.account = Account()
self.account.set_hash_and_key()
# self.account.source_name = self.user.nick() # More useful default than None
self.account.put()
# Create default Desktop Notifier
o = Outlet(target=self.account, type_name="DesktopNotifier")
o.set_name("Default Desktop Notifier")
o.put()
# This is to update existing accounts before outlets
if not self.account.get_default_outlet():
# Create default Desktop Notifier
o = Outlet(target=self.account, type_name="DesktopNotifier")
o.set_name("Default Desktop Notifier")
o.put()
for channel in Channel.get_all_by_target(self.account):
if not channel.outlet:
channel.outlet = o
channel.put()
else:
self.logout_url = None
self.account = None
self.login_url = users.create_login_url(request.path)
# Hide the Get Started tip
if request.query_string == "hide":
self.account.started = True
self.account.put()
def render(self, template_path, locals):
locals.update(
{
"user": self.user,
"logout_url": self.logout_url,
"login_url": self.login_url,
"account": self.account,
"api_host": API_HOST,
"api_version": API_VERSION,
"www_host": WWW_HOST,
}
)
self.response.out.write(template.render(template_path, locals))
示例3: test_verify_existing_user
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import set_hash_and_key [as 别名]
def test_verify_existing_user():
"""
Should return 200
"""
user = users.User("[email protected]")
account = Account(user=user)
account.set_hash_and_key()
account.put()
response = app.get("/v1/users/%s?api_key=%s" % (account.hash, account.api_key), status=200)
assert response.body == "200 OK"
test.reset_datastore()
示例4: test_verify_non_existing_user
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import set_hash_and_key [as 别名]
def test_verify_non_existing_user():
"""
Should return a 404 if userhash does not have a Notify.io account
"""
user = users.User("[email protected]")
account = Account(user=user)
account.set_hash_and_key()
account.put()
response = app.get("/v1/users/abcdef?api_key=%s" % account.api_key, status=404)
assert response.body == "404 User not found"
test.reset_datastore()