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


Python User.get_by_id方法代码示例

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


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

示例1: get_user_address

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
 def get_user_address(self):
     user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
     if user:
         if user.address:
             return user.address.address_from
     else:
         return ''
开发者ID:chuydb,项目名称:usocialmaps,代码行数:9,代码来源:models.py

示例2: login

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
	def login( self ):
		login = self.request.get( 'login', None );
		password = self.request.get( 'password', None );
		logging.info( "login=%s password=%s" % (login,password) );

		# パラメータチェック
		if (login is None) or (password is None):
			out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="login and password required") };
			logging.error( "login and password required" );
			self.response.out.write( json.encode(out) )
			return

		# ログインしようとしているユーザーがメアドを verify 済みかチェック
		auth_id = "own:"+ login
		m = self.user_model
		q = m.query( m.auth_ids==auth_id, m.verified==True )
		result = q.get();
		if result is None:
			out = { "meta": functions.createMetaData( status="fail", code=400, cc_code=1000, message="ユーザーが存在しないか、メールアドレス認証が完了していません") };
			logging.error( "ユーザーが存在しないか、メールアドレス認証が完了していません" );
			self.response.out.write( json.encode(out) )
			return

		user = None
		userInfo = self.auth.get_user_by_password( "own:"+ login, password, True, True, True )

		# 2013/01/06 以前のバージョンは頭に「own:」がついてなかったので、それにも対応。	
		if userInfo is None:
			logging.info( "2013/01/06 以前のバージョン方式でログインします" );
			userInfo = self.auth.get_user_by_password( login, password, True, True, True )

		if userInfo is None:
			# ログイン失敗
			logging.error( "Invalid email/username or password." );
			out = {
				"meta": functions.createMetaData(
					status="fail", code=401, cc_code=1000, message="Invalid email/username or password."
				),
			};
			self.response.out.write( json.encode(out) )
			return
		
		# ログイン成功
		user = User.get_by_id( userInfo["user_id"] )
		sessionId = self.serialize_user_token( auth_info=userInfo )
		out = {
			"meta": {
				"status": "ok",
				"code": 200,
				"method_name": "loginUser",
				"session_id": sessionId,
			},
			"response":{
				"users": [
					user.toDict( full=True ),
				],
			},
		};	
		self.response.out.write( json.encode(out) )
开发者ID:noughts,项目名称:openfish,代码行数:61,代码来源:users.py

示例3: get_group_users

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
	def get_group_users(cls, group):
		users = []
		entries = cls.query().filter(cls.group == group, cls.active == True).fetch()
		for entry in entries:
			stuff = entry.member
			user = User.get_by_id(entry.member.id())
			users.append(user)
		return users
开发者ID:StackMonkey,项目名称:site,代码行数:10,代码来源:models.py

示例4: post

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
 def post(self,userid):
     print userid
     url = images.get_serving_url(self.get_uploads()[0].key())
     user = User.get_by_id(int(userid))
     print user
     user.img = url;
     user.put();
     self.response.write(resp.success())
开发者ID:jaredwindover,项目名称:SetScouter,代码行数:10,代码来源:Photo.py

示例5: getCurrentUser

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
	def getCurrentUser( cls ):
		logging.error( "現在 getCurrentUser にはバグがあります" )
		if cls.userCache=="notInitialized":
			myAuth = auth.get_auth()
			userInfo = myAuth.get_user_by_session()
			if userInfo:
				cls.userCache = User.get_by_id( userInfo["user_id"] )
			else:
				cls.userCache = None
		return cls.userCache
开发者ID:noughts,项目名称:openfish,代码行数:12,代码来源:models.py

示例6: post

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
    def post(self, token):
        if self.form.validate():
            token = User.token_model.query(User.token_model.token == token).get()
            # test current password
            user = User.get_by_id(int(token.user))
            if token and user:
                user.password = security.generate_password_hash(self.form.password.data, length=12)
                user.put()
                # Delete token
                token.key.delete()
                # Login User
                self.auth.get_user_by_password(user.auth_ids[0], self.form.password.data)
                self.add_message('Password changed successfully', 'success')
                return self.redirect_to('profile-show', id=user.key.id())

        self.add_message('Please correct the form errors.', 'error')
        return self.get(token)
开发者ID:Joelone,项目名称:gae-boilerplate,代码行数:19,代码来源:handlers.py

示例7: get_user_phone

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
 def get_user_phone(self):
     user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
     if user:
         return user.phone
     else:
         return ''
开发者ID:chuydb,项目名称:usocialmaps,代码行数:8,代码来源:models.py

示例8: get_user_lastname

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
 def get_user_lastname(self):
     user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
     if user:
         return user.last_name
     else:
         return ''
开发者ID:chuydb,项目名称:usocialmaps,代码行数:8,代码来源:models.py

示例9: get_user_email

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_id [as 别名]
 def get_user_email(self):
     user = User.get_by_id(long(self.user_id)) if self.user_id != -1 else None
     if user:
         return user.email
     else:
         return ''
开发者ID:chuydb,项目名称:usocialmaps,代码行数:8,代码来源:models.py


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