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


Python User.put方法代码示例

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


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

示例1: test_oauth2callback_path_succeeds_for_existing_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
    def test_oauth2callback_path_succeeds_for_existing_user(self):
        google_api.httplib2.Http = MockHttp

        # Create dummy user
        now  = datetime.now()
        user = User(profile_slug='dummy_user', google_id='12345', created_at=now, last_login_at=now, modified_at=now)
        user.put()
        num_users = User.all().count()

        response = main.app.get_response('/auth/oauth2callback?code=abc123')

        # Ensure existing user record has been updated with info from Google (data/user_info.json)
        user = User.get_by_google_id('12345')
        self.assertEqual(num_users,               User.all().count())
        self.assertEqual(user.google_birthday,    '0000-01-01')
        self.assertEqual(user.google_email,       '[email protected]')
        self.assertEqual(user.google_gender,      'male')
        self.assertEqual(user.google_locale,      'en-GB')
        self.assertEqual(user.google_name,        'Dummy User')
        self.assertEqual(user.google_picture_url, 'https://lh3.googleusercontent.com/photo.jpg')

        # Ensure correct response
        self.assertEqual(response.status_int, 302)
        self.assertTrue('Location' in response.headers)
        self.assertTrue('http://localhost/' in response.headers['Location'])
开发者ID:opendatapress,项目名称:open_data_press,代码行数:27,代码来源:test_session.py

示例2: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
    def create_user(self, request):
        """Creates a User.
        Args:
            request: The USER_REQUEST objects, which includes a users
                chosen name and an email.
        Returns:
            StringMessage: A message that is sent to the client, saying that
                the user has been created.
        Raises:
            endpoints.BadRequestException: If no user name is provided.
            endpoints.ConflictException: If the user already exists.
            endpoints.BadRequestException: If no email is provided.
            endpoints.ConflictException: If a user with that email already exists.
        """
        if request.user_name is None:
            raise endpoints.BadRequestException(
                    'You must enter a user name to create a new user!')
        elif User.query(User.name == request.user_name).get():
            raise endpoints.ConflictException(
                    'A User with username {} already exists!'.format(request.user_name))

        if request.email is None:
            raise endpoints.BadRequestException(
                    'You must enter an email id to create a new user!')
        elif User.query(User.email == request.email).get():
            raise endpoints.ConflictException(
                    'A User with email {} already exists!'.format(request.email))

        # Create a new user with the user_name and email.
        user = User(name=request.user_name, email=request.email)
        # Add the user to the datastore with kind 'User'
        user.put()
        return StringMessage(message='User {} created!'.format(
                request.user_name))
开发者ID:geetimaRai,项目名称:hangmanAPI,代码行数:36,代码来源:api.py

示例3: saveUsertemp

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
	def saveUsertemp(self):
		# We determine first if some user information was already in the database
		user_query = User.all().filter("mail", self.usertemp.mail)
		existingUser = user_query.get()
		
		if(existingUser):
			user = existingUser
			user.label =  self.usertemp.label
			oldVcardRef = user.vcardRef
			oldImageRef= user.imageRef
			if(oldImageRef):
				oldImageRefID = str(oldImageRef.key().id())
			logging.info("User found: %s, %s" % (user.label, user.mail))
		else:
			user = User()
			oldVcardRef = None
			oldImageRef = None
			user.label =  self.usertemp.label
			user.mail = self.usertemp.mail
				
		if(self.usertemp.imageRef):
			# We replace the old image Ref/ (or if not found) add the new image Ref
			user.imageRef = self.usertemp.imageRef
			
			# If there was an old image ref, we have to delete the image in the blobstore, in the Moodstocks DB and the reference in the Datastore
			if(oldImageRef):
				
				# We delete the image from Moodstocks DB
				moodstocksHandler = Moodstocks()
				moodstocksHandler.deleteObject(oldImageRefID)
				
				# We delete the image in the blobstore
				blobInfo = oldImageRef.blobKey
				oldBlobKey = blobInfo.key()
				blobstore.delete(oldBlobKey)
				
				# We delete the existing image Ref
				oldImageRef.delete()
						
		if(self.usertemp.vcardRef):
			# We replace the old vcard Ref/ (or if not found) by the new vcard Ref
			user.vcardRef = self.usertemp.vcardRef
			
			# If there was an old vcard ref, we have to delete it from to datastore
			if(oldVcardRef):
				oldVcardRef.delete()

		user.put()
		self.usertemp.delete()
		
		path = None
		if(user.imageRef):
			if(user.vcardRef):
				path = os.path.join(os.path.dirname(__file__), 'templates/post/all_set.html')
			else:
				path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_vcard_missing.html')
		else:
			path = os.path.join(os.path.dirname(__file__), 'templates/post/almost_set_image_missing.html')
		
		self.response.out.write(template.render(path, None))
开发者ID:detcherry,项目名称:capturio,代码行数:62,代码来源:post_capturio_confirmation.py

示例4: getUserObject

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def getUserObject(self, user = None):
     
     from google.appengine.api import users
     from models.user import User
     
     if user == None:
         user = users.get_current_user()
     
     userId = self.getUserId(user)
     if not userId:
         return None
     
     query = User.all()
     query.filter("id =", userId)
     userObject = query.get()
     
     if userObject == None:
         if type(user) == users.User:
             userObject = User(
                 id = userId,
                 username = user.nickname().split('@')[0],
                 name = user.nickname().split('@')[0]
             )
         else:
             userObject = User(
                 id = userId,
                 username = userId,
                 name = userId
             )
         userObject.put()
     
     return userObject
开发者ID:peej,项目名称:to.uri.st,代码行数:34,代码来源:controller.py

示例5: get

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

        if user:
            # Filter by the google appengine user id property.
            active_user = User.query(User.google_id == user.user_id()).fetch(1)

            if not active_user:
                # If we couldn't find a user it means that is the first time it uses the application.
                # We just need to create a new entity with the get_current_user() information.
                active_user = User(email=user.email(), username=user.nickname(), google_id=user.user_id())
                active_user.put()
                logging.info("New user created. Email address is: %s", active_user.email)
            else:
                active_user = active_user[0]

            token = channel.create_channel(str(active_user.key.id()))
            memcache.add(key=str(active_user.key.id()), value=token)

            template_vars = {
                'user': active_user,
                'token': token,
                'logout_url': users.create_logout_url('/welcome'),
                'boards': Board.query().order(Board.created_at)

            }
            template = JINJA_ENVIRONMENT.get_template('root.html')
            self.response.write(template.render(template_vars))
        else:
            self.redirect('/welcome')
开发者ID:bilby91,项目名称:ganban,代码行数:32,代码来源:web.py

示例6: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
    def get(self):
        if self.request.get('userid'):
            user_info = flickr.FlickrUserInfo("", self.request.get('userid'), self.request.get('userid'), "")
        else:
            frob = self.request.get('frob')                        
            
            try:
                user_info = flickr.get_user_info(frob)
            except:
                user_info = flickr.get_user_info(frob)                
        
    
        user = User.get_by_key_name(user_info.nsid)
        
        session = Session()

        if user is None:
            user = User(key_name = user_info.nsid,
                        username = user_info.username,
                        fullname = user_info.fullname, 
                        token    = user_info.token,     
                        status   = const.UserRegistred,                      
                        last_login = datetime.datetime.now())
                     
        task = None
        
        if not user.is_saved() or user.status == const.UserUnRegistred:
            task = taskqueue.Task(url="/task/user/update_contacts", 
                                  params={'key':user.key(), 'update_favorites':True, 'initial_update': True})                           
        
        user.status = const.UserRegistred
        user.username = user_info.username
        user.fullname = user.fullname
        user.token = user_info.token
        
        if os.environ.get('SERVER_SOFTWARE') == 'Development/1.0':
            user.token = '72157623100491721-4ab7039d8e6b4615' 
        #user.token = '72157622500427269-7131c791b2204f16'
        user.last_login = datetime.datetime.now()
        
        try:
            user.put()
        except:
            user.put()
        
        if task:
            task.add("non-blocking")
        
        session["username"]   = user.username
        
        if user.fullname:
            session["fullname"]   = user.fullname
            
        session["nsid"]     = user.nsid
        session["auth_token"] = user.token
        
        session["difficulty"] = user.difficulty
        session["layout"] = user.layout        
                                                                        
        self.redirect("/dashboard")
开发者ID:buger,项目名称:flick_faver,代码行数:62,代码来源:main.py

示例7: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
	def post(self):
		fname = self.request.get("first_name")
		lname = self.request.get("last_name")
		dname = self.request.get("display_name")
		email = self.request.get("email")
		password = self.request.get("password")
		rpassword = self.request.get("password_confirmation")

		#logging.critical(email)

		if password != rpassword:
			self.error = "Password Not Match"
			self.redirect('/create/account?error='+self.error)

		user = User.get_by_id(id=email)
		logging.critical(user)

		if user:
			self.error = "Email already exists!"
			self.redirect('/create/account?error='+self.error)

		user = User(id=email)
		user.fname = fname
		user.lname = lname
		user.dname = dname
		user.email = email
		user.password = password
		user.put()
		self.logged_this_user(user)
		self.tv["user"] = True
		self.redirect('/dashboard')
开发者ID:rcasona,项目名称:pythonsample,代码行数:33,代码来源:admin.py

示例8: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def post(self):
     user = User(account=users.get_current_user(),
                 name=self.request.get('name', ''),
                 title=self.request.get('title', ''),
                 company=self.request.get('company', ''),
                 admin=(u'on' == self.request.get('admin', False)))
     user.put()
开发者ID:LHBDev,项目名称:211-WebApp,代码行数:9,代码来源:users.py

示例9: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
    def get(self):
        c = h.context()
        logging.info("***Auth2")
        cookies = h.get_default_cookies(self)
        c['cookies'] = cookies
        logging.info("***cookies: "+str(cookies))
        c['access_token'] = self.request.get("access_token")
        
        if self.request.get("access_token") == '':
            logging.error("No access token set, but we expected on %s" % str(self.request.url))
        else:
            logging.warning("Got access token %s" % self.request.get("access_token"))
        
        user = User.gql("WHERE fb_oauth_access_token = :1", self.request.get("access_token")).get()
        if user != None:
            # If the user currently exists in the DB
            logging.info("***SCU1")
            h.set_current_user(cookies, user)
            logging.info("***cookies: "+str(cookies))
            c['current_user'] = user
        else: 
            # Look user up in graph, and either find them in the DB or create them if they don't exist
            try:
                graph = facebook.GraphAPI(self.request.get("access_token"))
                me = graph.get_object('me')
            except Exception, e:
                logging.error(
                    "ERROR!  Failed to access Facebook Graph for access_token=" + 
                    self.request.get("access_token") +
                    "::" + str(e)) 
                me = None
                c['error'] = e

            if me != None:
                og_user = User.gql("WHERE fb_user_id = :1", str(me['id'])).get()
                
                if og_user == None:
                    new_user = User(
                        fb_user_id = str(me['id']),
                        fb_oauth_access_token = self.request.get("access_token"),
                        fb_oauth_access_token_stored_at = datetime.datetime.utcnow(),
                        first_name = me['first_name'], 
                        last_name = me['last_name'])
                    if 'email' in me:
                        new_user.email = me['email']
                    new_user.put()
                    logging.info("***SCU2")
                    h.set_current_user(cookies, new_user)
                    logging.info("***cookies: "+str(cookies))
                    c['current_user'] = new_user
                    
                else: # Update auth token for user because it's out of date
                    og_user.fb_oauth_access_token = self.request.get("access_token")
                    og_user.fb_oauth_access_token_stored_at = datetime.datetime.utcnow()
                    og_user.put()
                    logging.info("***SCU3")
                    h.set_current_user(cookies, og_user)
                    logging.info("***cookies: "+str(cookies))
                    c['current_user'] = og_user
开发者ID:codemuseum,项目名称:mykaribu2,代码行数:61,代码来源:main.py

示例10: create_new_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def create_new_user(self, username, email, googleID):
     new_user = User()
     new_user.populate(
         username = username,
         googleID = googleID,
         email = email,
         )
     new_user.put()
开发者ID:qdonnellan,项目名称:lessonwell,代码行数:10,代码来源:fetch_user_test.py

示例11: create_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def create_user(self, request):
     """Create a User. Requires a unique username"""
     if User.query(User.name == request.user_name).get():
         raise endpoints.ConflictException(
                 'A User with that name already exists!')
     user = User(name=request.user_name, email=request.email)
     user.put()
     return StringMessage(message='User {} created!'.format(
             request.user_name))
开发者ID:TomMuehlegger,项目名称:full_stack_web_developer,代码行数:11,代码来源:api.py

示例12: members

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
def members():
  if not g.user:
    return redirect(url_for('main'))
  user = User.get_from_google_user(g.user)
  if not user:
    user = User()
    user.initialize(g.user)
    user.put()
    flash('Created a new user')
  return render_template('members.html',user=user)
开发者ID:russorat,项目名称:savageautomation-tools,代码行数:12,代码来源:main.py

示例13: get_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
def get_user(request):
    if User.query(User.name == request.user_name).get():
        raise endpoints.ConflictException(
            'A User with that name already exists!')
    user = User(name=request.user_name, email=request.email)
    user.put()
    # Instantiates a new Leaderboard entity for the user
    leaderboard = Leaderboard(user=user.key, total_games_played=0, total_games_won=0, total_games_lost=0, user_name=user.name)
    leaderboard.put()
    return user.name
开发者ID:danrhjones,项目名称:GameApi,代码行数:12,代码来源:hangman.py

示例14: test_simple_creation_of_new_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def test_simple_creation_of_new_user(self):
     '''
     test a simple put() of a new user model 
     '''
     new_user = User()
     new_user.populate(
         username = 'foo',
         googleID = '123',
         email = '[email protected]',
         )
     new_user.put()
     self.assertEqual(User.query().count(), 1)
开发者ID:qdonnellan,项目名称:lessonwell,代码行数:14,代码来源:user_test.py

示例15: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import put [as 别名]
 def get(self):
   values = {}
   values.update(self.CommonValues())
   # Search for a user, and if none, create one
   userid = users.get_current_user()
   user = User.get_by_key_name(userid.nickname())
   if not user:
       user = User(key_name=userid.nickname())
       user.userid = userid
       user.put()
       logging.info("Created user %s", userid.nickname())
   values.update(user=user)
   self.response.out.write(template.render("templates/user.html", values))
开发者ID:Idrissa,项目名称:AlloSanteMob,代码行数:15,代码来源:user.py


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