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


Python User.get_by_id方法代码示例

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


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

示例1: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [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

示例2: get

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
 def get(self):
     user_id = self.request.cookies.get("user_id")
     if user_id and make_secure_value(user_id.split('|')[0]) == user_id:
         username = User.get_by_id(int(user_id.split('|')[0])).username
         self.render("welcome.html",name = username)
     else:
         self.redirect("/blog/signup")
开发者ID:harikrish00,项目名称:blogit,代码行数:9,代码来源:welcome.py

示例3: user_blogs

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def user_blogs(user_id=None):
	if user_id is not None:
		user = User.get_by_id(user_id)
	else:
		user = User.get_by_email(sesssion['email'])

	blogs = user.get_blogs()

	return render_template('user_blogs.html', blogs=blogs, email=user.email)
开发者ID:asimonia,项目名称:web-blog,代码行数:11,代码来源:app.py

示例4: get_current_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def get_current_user(session_user):
	if session_user.has_key("user"):
		user = User.get_by_id(session_user["user"])
		if user:
			return user
		else:
			return {}
	else:
		return None
开发者ID:rcasona,项目名称:pythonsample,代码行数:11,代码来源:session.py

示例5: authenticate

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def authenticate(request):
    user = None
    user_hash = request.cookies.get('user')
    user_id = security.validate_hash(user_hash)

    if user_id:
      user = User.get_by_id(long(user_id))

    return user
开发者ID:gokhanbarisaker,项目名称:CS-253-Web-Development,代码行数:11,代码来源:authenticator.py

示例6: get_attendings

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
 def get_attendings(self, ev_id, user_id, fb_token=None):
     us = User.get_by_id(user_id)
     token = None
     fb_id = None
     if us is not None:
         fb_id = us.fb_id
     if Event.get_by_id(ev_id) is None:
         return 1
     results = Attendings.query(Attendings.event_id == ev_id)
     return self.json_format_attendees(results, fb_token, fb_id, user_id)
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:12,代码来源:DAL.py

示例7: first_login

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def first_login(id=None):
    from models.user import UserSmallForm
    if 'logged_in' not in session:
        return redirect(url_for('welcome'))

    user = User(id=id)
    user = user.get_by_id()

    form = UserSmallForm(obj=user)

    return render_template('first_login.html', user=user, form=form)
开发者ID:acarmisc,项目名称:zombietweet,代码行数:13,代码来源:controller.py

示例8: get_user_details

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
 def get_user_details(user_id, fbf=None):
     user_details = dict()
     user = User.get_by_id(user_id)
     if user is not None:
         user_details['name'] = user.first_name
         user_details['lastname'] = user.last_name
         if fbf is not None:
             user_details['fbf'] = fbf
             user_details['id'] = user.fb_id
         return user_details
     else:
         return 1
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:14,代码来源:DAL.py

示例9: unattend

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
 def unattend(u_key, e_key):
     event1 = Event()
     qry = User.get_by_id(u_key)
     if qry is None:
         return 1
     if Event.get_by_id(e_key) is None:
         return 2
     attendings1 = Attendings()
     q = attendings1.check_attend_exist(u_key, e_key)
     if q:
         q.key.delete()
         event1.update_attendees(e_key, action="sub")
     return 0
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:15,代码来源:DAL.py

示例10: post

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
    def post(self):
        if self.request.POST.get('Body') is None or self.request.POST.get('From') is None:
            logging.error('Body and From params required')
            return self.abort(400, 'Body and From params required')

        user_message = Message(
            text=self.request.POST.get('Body').strip(),
            receiver=self.request.POST.get('To'),
            sender=self.request.POST.get('From'),
            media_url=self.request.POST.get('MediaUrl0'),
        )

        from_phone = self.request.get('From')
        logging.info('Received text from %s with media: %s message:\n%s', from_phone, user_message.media_url, user_message.text)

        user = User.get_by_id(from_phone)
        if user:
            logging.info('Found existing user for %s', from_phone)
        else:
            logging.info('Creating new user for %s', from_phone)
            user = User(id=from_phone)

        message_type = determine_message_type(user_message.text)
        logging.info('Message of type: %s', message_type)
        group = user.group
        response_type, messages, user, group = perform_action(message_type, user_message, user, group)
        responses = [format_message(m, user, group) for m in messages]
        logging.info('Responding with: %s', responses)
        self.response.body = twiml_response(user, group, response_type, responses)
        self.response.headers['Content-Type'] = 'text/xml'
        logging.info('Responding: %s', self.response.body)

        user_message.story_uid = group.story_uid if group else None
        user_message.group_uid = group.uid if group else None
        user_message.put()

        ndb.put_multi([Message(receiver=from_phone,
                               sender=m.sender or None,
                               text=m.text,
                               media_url=m.media_url,
                               group_uid= group.uid if group else None,
                               story_uid=group.story_uid if group else None)
                       for m in responses])

        if group:
            group.put()
            user.group_uid = group.uid
        else:
            user.group_uid = None
        user.put()
开发者ID:ChrisPenner,项目名称:scavenger,代码行数:52,代码来源:scavenger.py

示例11: user_blogs

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def user_blogs(user_id=None):
    if user_id is not None:
        user = User.get_by_id(user_id)
    else:
        user = User.get_by_email(session['email'])
        
    blogs = user.get_blogs()
    
    blog_id = request.args.get('bg')
    
    if blog_id is not None:
        blog = Blog.from_mongo(blog_id)
        posts = blog.get_posts()
        return render_template("user_blogs.html", blogs=blogs, email=user.email,posts=posts, blog_title=blog.title, blog_id=blog._id)
    
    return render_template("user_blogs.html", blogs=blogs, email=user.email)
开发者ID:wmsgood,项目名称:Mongoblog,代码行数:18,代码来源:app.py

示例12: json_format_attendees

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
    def json_format_attendees(self, query_res, token, fb_id, my_id):
        users = list()
        fb_friends = fb_logic.get_fb_friends(token)

        if fb_friends is None:
            fb_friends = []
        for res in query_res:
            fbf = "false"
            for f in fb_friends:
                qry = User.get_by_id(res.user_id)
                if qry is not None:
                    if int(f) == qry.fb_id:
                        fbf = "true"
            if res.user_id != my_id: #do not return myself!
                user = self.get_user_details(res.user_id, fbf)
                if user != 1:
                    users.append(user)
        return json.dumps(users)
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:20,代码来源:DAL.py

示例13: attend

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
    def attend(u_key, e_key):
        event1 = Event()
        attendings1 = Attendings()

        qry = User.get_by_id(u_key)
        logging.info("query is : {}".format(qry))
        if qry is None:
            return 1
        else:
            attendings1.user_id = u_key
        if Event.get_by_id(e_key) is None:
            return 2
        else:
            attendings1.event_id = e_key
        if attendings1.check_attend_exist(u_key, e_key) is False:
            attendings1.put()
            event1.update_attendees(e_key, action="add")
        return 0
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:20,代码来源:DAL.py

示例14: get_user

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
def get_user(id=None):
    from models.user import UserSmallForm
    if 'logged_in' not in session:
        return redirect(url_for('welcome'))

    user = User(id=id)
    if request.method == 'POST':
        user.first_name = request.form.get('first_name', None)
        user.last_name = request.form.get('last_name', None)
        user.email = request.form.get('email', None)
        user.update_user()

    user = user.get_by_id()

    form = UserSmallForm(obj=user)

    schedule = Schedule(uid=id)
    schedules = schedule.get_by_logged_user(user.username, timeadapt=True)

    return render_template('user.html', user=user, form=form,
                           schedules=schedules)
开发者ID:acarmisc,项目名称:zombietweet,代码行数:23,代码来源:controller.py

示例15: check_token

# 需要导入模块: from models.user import User [as 别名]
# 或者: from models.user.User import get_by_id [as 别名]
 def check_token(self, token):
     if User.get_by_id(token) is None:
         return False
     else:
         return True
开发者ID:ItamarShDev,项目名称:attender-web,代码行数:7,代码来源:DAL.py


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