本文整理汇总了Python中user_app_client.UserAppClient.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python UserAppClient.create_user方法的具体用法?Python UserAppClient.create_user怎么用?Python UserAppClient.create_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类user_app_client.UserAppClient
的用法示例。
在下文中一共展示了UserAppClient.create_user方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user_accounts
# 需要导入模块: from user_app_client import UserAppClient [as 别名]
# 或者: from user_app_client.UserAppClient import create_user [as 别名]
def create_user_accounts(cls, email, password, uaserver_host, keyname):
"""Registers two new user accounts with the UserAppServer.
One account is the standard account that users log in with (via their
e-mail address. The other is their XMPP account, so that they can log into
any jabber-compatible service and send XMPP messages to their application
(and receive them).
Args:
email: The e-mail address that should be registered for the user's
standard account.
password: The password that should be used for both the standard and XMPP
accounts.
uaserver_host: The location of a UserAppClient, that can create new user
accounts.
keyname: The name of the SSH keypair used for this AppScale deployment.
"""
uaserver = UserAppClient(uaserver_host, LocalState.get_secret_key(keyname))
# first, create the standard account
encrypted_pass = LocalState.encrypt_password(email, password)
uaserver.create_user(email, encrypted_pass)
# next, create the XMPP account. if the user's e-mail is [email protected], then that
# means their XMPP account name is [email protected]_ip
username_regex = re.compile('\A(.*)@')
username = username_regex.match(email).groups()[0]
xmpp_user = "{0}@{1}".format(username, LocalState.get_login_host(keyname))
xmpp_pass = LocalState.encrypt_password(xmpp_user, password)
uaserver.create_user(xmpp_user, xmpp_pass)
AppScaleLogger.log("Your XMPP username is {0}".format(xmpp_user))