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


Python User.put方法代码示例

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


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

示例1: create_new_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
    def create_new_user(self, user_keyname, password, set_user=True, **kwargs):
        logging.info('creating user with keyname %s' % user_keyname)
        user_entity = User(key_name=user_keyname, username=user_keyname)
        if password:
            user_entity.password = password
        if '@passtiche.appspot.com' not in user_keyname and not user_keyname.startswith('auto_gen'):
            deferred.defer(send_admin_email, subject='New %s User: %s' % (
                 self._settings['title'], user_keyname),        
                message='User %s just signed up for an account' % user_keyname,
                user=user_keyname, user_agent=gae_utils.GetUserAgent(), url=gae_utils.GetUrl())
        if '@' in user_keyname:
            user_entity.email = user_keyname
            
            #send_welcome_email(user_entity.email, 'Welcome to %s!' % self._settings['title'])
            deferred.defer(send_welcome_email, 
                user_entity, 
                'Welcome to %s!' % self._settings['title'], 
                _countdown=10) # 1300 22 minutes

        # optional args
        for k in ['first_name', 'last_name','phone','organization']:
            if kwargs.get(k):
                v = kwargs.get(k)
                setattr(user_entity, k, v)

        from utils import string as str_utils
        code = str_utils.genkey(length=7)
        user_entity.short_code = code

        user_entity.put()
        if set_user:
            self.set_current_user(user_entity)
        return user_entity 
开发者ID:jamslevy,项目名称:passtiche,代码行数:35,代码来源:base.py

示例2: _process_users

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
    def _process_users(self, session, **kwargs):
        modified_voters = set()
        new_user = None
        if "new_voter" in kwargs and kwargs["new_voter"]:
            new_user = User(name=kwargs["new_voter"])
            new_user.put()

            user_by_session = UserBySession(user=new_user, session=session)
            user_by_session.put()

        voter_keys = []
        if "voter_key" in kwargs:
            voter_keys = [kwargs["voter_key"]]
            if isinstance(kwargs["voter_key"], list):
                voter_keys = voter_keys[0]

            if "voter_name" in kwargs and not isinstance(kwargs["voter_name"], list):
                kwargs["voter_name"] = [kwargs["voter_name"]]

            for i in range(len(voter_keys)):
                voter = User.get(voter_keys[i])
                voter.name = kwargs["voter_name"][i]
                voter.put()
                modified_voters.add(voter)

        return (new_user, modified_voters)
开发者ID:mtambos,项目名称:brainstormcracy,代码行数:28,代码来源:brainstorming_session.py

示例3: new_or_existing_ga

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def new_or_existing_ga(user, alias_suggestion=None):
    #id = unicode(type(user).__name__.lower() +':'+ user.user_id())
    id = unicode('ah:'+ user.user_id())
    entity = User.get_by_key_name(id)
    if not entity:
        entity = User(key_name=id, email=user.email())
        entity.put()
        logger.debug("Created user %s (%s)", entity.email, entity.key().name())
        #if alias_suggestion and not find_alias(alias_suggestion):
        #    alias = new_alias(entity, alias_suggestion)
        #else:
        #    alias = new_alias_for(entity)
        #assert alias, "FIXME: Cannot create Alias for %s" % user.email()
        #alias.put()
        #logger.debug("Created alias %s for user (%s).", alias.handle, entity.key().name())

    elif entity.email != user.email():
        entity.email = user.email()
        entity.put()
        #alias = new_alias_for(entity)
        #if alias:
        #    logger.debug("Updating user %s for alias %s. ", user.email(), newalias)
        #    alias.put()
        #else:
        #    logger.info("New alias not available for user %s. ", user.email())

    return entity
开发者ID:dotmpe,项目名称:Blue-Lines,代码行数:29,代码来源:api.py

示例4: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
 def post(self):
     if not self.validate(self.request):
         self.render_form()
     else:
         user = User(name=self.username, password_hash=Hash.password(self.username, self.password), email=(self.email if self.email else None ))
         user.put()
         self.set_cookie('userid', user.key())
         self.redirect('/blog/home')
开发者ID:M4573R,项目名称:udacity-1,代码行数:10,代码来源:hw4.py

示例5: new_or_existing_email

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def new_or_existing_email(email):
    mbox_sha1 = hashlib.sha1(email).hexdigest()
    id = unicode('bl:'+ mbox_sha1)
    entity = User.get_by_key_name(id)
    if not entity:
        entity = User(key_name=id, email=email)
        entity.put()
    else:
        logger.error("TODO: implement user authentication. ")
    return entity
开发者ID:dotmpe,项目名称:Blue-Lines,代码行数:12,代码来源:api.py

示例6: fetch_and_save_github_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def fetch_and_save_github_user(access_token):
	response = json.loads(urlfetch.fetch(github.USER_EMAILS_URL%access_token).content)
	for email in response:
		if email['primary']:
			logging.info(email['email'])
			user = User.get_by_key_name(email['email'])
	if not user:
		user = User(key_name=email['email'])
		user.put()
	response = json.loads(urlfetch.fetch(github.USER_URL%access_token).content)
	id, followers = response['login'], response['followers']
	ThirdPartyUser(key_name=GITHUB, parent=user, access_token=access_token, id=id, followers=followers).put()
开发者ID:ashray-velapanur,项目名称:moonlancer,代码行数:14,代码来源:auth.py

示例7: get_user_or_letlogin

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
def get_user_or_letlogin(ctrl, dest_url='/'):
    from google.appengine.api import users
    guser = users.get_current_user()
    if not guser:
        ctrl.redirect(users.create_login_url(dest_url))
        return None

    user = User.get_by_key_name(guser.email())
    if not user:
        user = User(key_name=guser.email(), email=guser.email())
        user.put()
    return user
开发者ID:chihchun,项目名称:bebebe,代码行数:14,代码来源:auth.py

示例8: post

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
	def post(self):
		isUser = User.query(User.username == self.request.get('username')).get()
		if((isUser is None) and (self.request.get('confirm') == self.request.get('password')) and validation(self.request.get('email'))):
			hashsum = hashlib.md5(self.request.get('password')).hexdigest()
			users = User(username = self.request.get('username'),
                    	password=hashsum )
			users.put()
			return webapp2.redirect('/')
		else:
			templatevalues = {
            	'user_log' : checkcookies(self),
			} 
			template = jinja_environment.get_template('error.html')
			self.response.out.write(template.render({'templatevalues':templatevalues}))
开发者ID:mmazurkevich,项目名称:GoogleAppEngine,代码行数:16,代码来源:user_controller.py

示例9: create_user

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
 def create_user(self, req_handler):
     photos = self.get_uploads("uploaded_photo")
     photo = self['image']
     email = req_handler['email']
     if photos:
         photo_blob_key = photos[0].key()
         photo = '/api/common/download_image/'+str(photo_blob_key)
     password_hash = generate_password_hash(req_handler['password'])
     user = User(key_name = email, name = req_handler['name'], password = password_hash, photo = photo)
     intercomio_api.users(email=email, name=req_handler['name'], signed_up_at=int(time.time()))
     intercomio_api.events(email=email, event_name='signedup')
     mixpanel_api.users(email, req_handler['name'])
     mixpanel_api.events(email, 'signedup')
     user.put()
开发者ID:aiyappaganesh,项目名称:underdogs,代码行数:16,代码来源:users.py

示例10: join_game

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
    def join_game(self, game, name):
        sess      = User(uid = uuid.uuid4().hex)
        sess.secret = channel.create_channel(sess.uid)
        sess.gid  = game.gid;
        sess.name = name
        sess.put()

        self.response.set_cookie('Session', sess.uid)

        # We don't need to save this as create() has more stuff to add
        game.members.append(sess.name)

        self.user = sess

        # The userid
        return sess.uid
开发者ID:EmilyShepherd,项目名称:Xanten-Game,代码行数:18,代码来源:game_handler.py

示例11: testUserCreate

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
  def testUserCreate( self ):
    self.setup_admin_user()
    u = users.get_current_user()

    self.isNotNone( u )

    _lu = User(
      user = u,
      email = u.email(),
      is_blog_owner = users.is_current_user_admin()
    )

    _lu.put()

    self.assertEquals( _lu.email, u.email() )
    self.assertEquals( User.all().count(), 1 )
    self.assertEquals( User.all().get().user, u )
开发者ID:gvenkat,项目名称:bottled,代码行数:19,代码来源:test_user.py

示例12: create

# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import put [as 别名]
 def create(self):
     """
     Create the ID
     """
     try:
         # retrieve the parameters
         u = self.params['user']
         
         if len(u['name']) < 2 or len(u['name']) > 16:
             raise 'ID 長度有誤'
             
         from google.appengine.api import users
         from model.user import User
         from model.counter import Counter
         from random import randint
         
         user = User.gql('WHERE name = :1', u['name']).get()
         if user is not None:
             raise 'ID 重覆'
         
         guser = users.get_current_user()
         # create user entity
         user = User(key_name=guser.email(),
                     name=u['name'],
                     email=guser.email())
         user.put()
         
         # add user counter
         shard_name = randint(0, 3)
         counter = Counter.get_by_key_name('user_counter_%d' % shard_name)
         if counter is None:
             counter = Counter(key_name='user_counter_%d' % shard_name, name="user_counter")
         counter.count += 1
         counter.put()
         
         if self.session.has_key('error'):
             del self.session['error']
             self.session.put()
         
         self.redirect('/auth')
     except Exception, ex:
         self.session['error'] = ex
         self.session.put()
         self.redirect('/signup')
开发者ID:chihchun,项目名称:bebebe,代码行数:46,代码来源:account.py


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