当前位置: 首页>>代码示例>>Python>>正文


Python User.create_user方法代码示例

本文整理汇总了Python中webapp2_extras.appengine.auth.models.User.create_user方法的典型用法代码示例。如果您正苦于以下问题:Python User.create_user方法的具体用法?Python User.create_user怎么用?Python User.create_user使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在webapp2_extras.appengine.auth.models.User的用法示例。


在下文中一共展示了User.create_user方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import create_user [as 别名]
 def post(self):
     self.response.headers['Content-Type'] = 'application/json'
     firstname = self.request.get('firstname')
     lastname = self.request.get('lastname')
     email = self.request.get('email')
     password = self.request.get('password')
     work, info = User.create_user(
         email,
         firstname=firstname,
         lastname=lastname,
         password_raw=password
     )
     if not work:
         self.response.write(resp.fail(
             'email',
             'Email address already exists'
         ))
     else:
         user = info
         token = User.create_auth_token(user.key.id())
         self.response.write(resp.success({
             'Token' : token,
             'User' : {
                 'firstname' : user.firstname,
                 'lastname' : user.lastname,
                 'email' : user.auth_ids[0],
                 'id' : user.key.id()
             }
         }))
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:31,代码来源:User.py

示例2: create_test_usersAction

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import create_user [as 别名]
 def create_test_usersAction(self):
     self.checkEnv()
     model=DevModel()
     page=0
     limit=100
     
     total=0
     
     """
     fusers=[1]
     fusers=User.query().fetch(200)
     for user in fusers:
         if user and user.email_address:
             if '@syytacit.com'==user.email_address[-13:]:
                 Unique.delete_multi( map(lambda s: 'User.auth_id:' + s, user.auth_ids) )
                 ndb.delete_multi([user.key])
                 total=total+1
     page=page+1
     logging.info("deleted "+str(total)+" records")
     model.messages.append("deleted "+str(total)+" records")
     return DevView(model)
     """
     
     page=0
     total=0
     file_contents=open("fake_users.txt").read()
     file_lines=file_contents.split("\n")
     num_new_users=0
     #userdata=open("a").read()
     salt='1da6452f43f349e4a73e2a8db17ab826';
     now=time.time()
     for line in file_lines:
         userdata=line.split(",")
         if len(userdata) >2:
             t1=now-random.randint(0,(86400*365))
             date_created=datetime.datetime.utcfromtimestamp(t1)
             
             user = User.create_user(userdata[0],email_address=userdata[0]+"@syytacit.com", password_raw=hashlib.md5(userdata[0]+salt).hexdigest(),verified=False,created=date_created)
             num_new_users=num_new_users+1
             #user=user(type="fake",nickname=userdata[0],first_name=userdata[1],last_name=userdata[2],email=userdata[0]+"@syytacit.com")
             #user.save()
     logging.info("created "+str(num_new_users)+" new users");
     model.messages.append("created "+str(num_new_users)+" new users")
     return DevView(model)
开发者ID:saidwords,项目名称:syytacit,代码行数:46,代码来源:BackupDevController.py

示例3: post

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import create_user [as 别名]
 def post(self):
     # set headers
     self.response.headers.add_header('Content-Type', 'application/json')
     form = UserForm(formdata=webob.multidict.MultiDict(json.loads(self.request.body or '{}')))
     form.validate()
     if form.errors:
         self.response.set_status(400)
         self.response.write(json.dumps(form.errors))
     else:
         created, info = User.create_user(form.email.data, password_raw=form.password.data, full_name=form.full_name.data)
         if created:
             self.response.set_status(201)
         else:
             self.response.set_status(400)
             errors = {
                 'auth_id': {
                     'key': 'email',
                     'msg': 'Email is already registered'
                 }
             }
             duplicates = {}
             for item in info:
                 duplicates[errors[item]['key']] = errors[item]['msg']
             self.response.write(json.dumps(duplicates))
开发者ID:carlitux,项目名称:test-gae,代码行数:26,代码来源:main.py

示例4: bootstrap

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import create_user [as 别名]
def bootstrap(password):
    User.create_user('giddingsl', password_raw=password)
开发者ID:Terhands,项目名称:saskdance,代码行数:4,代码来源:login.py


注:本文中的webapp2_extras.appengine.auth.models.User.create_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。