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


Python User.get_by_auth_id方法代码示例

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


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

示例1: add_quote

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
def add_quote(title1, user_id, user_anon, provider, quote1=None, url1=None, image=None, _created=None):
    try:
        now = datetime.datetime.now()

        if isinstance(user_id, unicode):
            auth_id = '%s:%s' % (provider, user_id)
            user = User.get_by_auth_id(auth_id)
        else:
            user = user_id

        unique_user = _unique_user(user)
        if _created:
            created = _created
        else:
            created = (now - datetime.datetime(2008, 10, 1)).days

        q = Post(
                title=title1,
                quote=quote1,
                created=created,
                image=image,
                creator_anonymous=user_anon,
                creator=user.key,
                creation_order=now.isoformat()[:19] + "|" + unique_user,
                uri=url1
        )
        q.put()

        add_search_index(q.key.id(), title1, quote1, url1, image, user, user_anon)
        return q.key.id()

    except db.Error:
        return None
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:35,代码来源:modals.py

示例2: set_vote

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
def set_vote(quote_id, user_id, newvote, provider):
    if user_id is None:
        return

    if isinstance(user_id, unicode):
        auth_id = '%s:%s' % (provider, user_id)
        user = User.get_by_auth_id(auth_id)
    else:
        user = user_id

    email = user.email

    def txn():
        quote = Post.get_by_id(quote_id)
        vote = Vote.get_by_id(id=email, parent=quote.key)
        if vote is None:
            vote = Vote(id=email, parent=quote.key)
        if vote.vote == newvote:
            return
        quote.votesum = quote.votesum - vote.vote + newvote
        vote.vote = newvote

        quote.rank = "%020d|%s" % (
            long(quote.created * DAY_SCALE + quote.votesum),
            quote.creation_order
        )
        quote.put()
        vote.put()
        memcache.set("vote|" + email + "|" + str(quote_id), vote.vote)

    ndb.transaction(txn)
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:33,代码来源:modals.py

示例3: add_comment

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
def add_comment(user, user_anon, quote_id, text, provider):
    try:
        if user is None:
            return

        if isinstance(user, unicode):
            auth_id = '%s:%s' % (provider, user)
            user = User.get_by_auth_id(auth_id)
        else:
            user = user

        quote = Post.get_by_id(long(quote_id))
        comment = Comment(
                parent=quote.key,
                author_anonymous=user_anon,
                author=user.key,
                text=text
        )
        quote.comments += 1

        quote.put()
        comment.put()
        memcache.set("comment|" + user.email + "|" + str(quote_id), comment.text)

    except db.Error:
        return None
开发者ID:yashrajsingh,项目名称:projectyello-appengine-backend,代码行数:28,代码来源:modals.py

示例4: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
    def get(self, username, term, syllabus):
        # Deal with possible trailing slash
        if syllabus[-1] == '/':
            syllabus = syllabus[:-1]

        user = User.get_by_auth_id(username)
        terms = user.terms
        
        if terms:
            for t in terms:
                if t.url == term.upper():
                    syllabi = t.syllabi
                    for syl in syllabi:
                        if syl.info.url.lower() == syllabus.lower():
                            if not syl.isActive:
                                currentUser = None
                                if self.user:
                                    currentUser = ndb.Key(User, self.user['user_id']).get()
                                if not currentUser or username not in currentUser.auth_ids:
                                    self.abort(403)
                            self.render(t, syl)
                            return

        # Raise HTTP 404 error for syllabi that don't exist
        self.abort(404)
开发者ID:koszuta,项目名称:CS361,代码行数:27,代码来源:preview.py

示例5: get_user

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
 def get_user(self):
     """
     Return the current :class:`google.appengine.api.users.User` or
     ``None``.
     """
     user = None
     auth_id = get_param(self.request.headers, _AUTH_ID_HEADER_KEY)
     if auth_id:
         try:
             user = User.get_by_auth_id(auth_id)
         except BadRequestError:
             _log.exception('Error getting user by auth_id: {}'.format(
                 auth_id))
     return user
开发者ID:RapidMVP,项目名称:spidernotes-gae,代码行数:16,代码来源:__init__.py

示例6: get

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
    def get(self, username, term):
        # TODO: Render weekly calendar template
        
        term = term.upper()
        user = User.get_by_auth_id(username)
        
        if user:
            terms = Term.query(ancestor = user.key).fetch()
        
            for t in terms:
                if t.url == term:
                    return self.render(user, t)

        # Raise HTTP 404 error for terms not yet available
        self.abort(404)
开发者ID:koszuta,项目名称:CS361,代码行数:17,代码来源:term.py

示例7: post

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
 def post(self):
     email = self.request.POST.get('email')
     auth_id = "own:%s" % email
     user = User.get_by_auth_id(auth_id)
     if user is not None:
         # Send Message Received Email
         taskqueue.add(url='/emails/password/reset', params={
             'recipient_id': user.key.id(),
             })
         _message = 'Password reset instruction have been sent to %s. Please check your inbox.' % email
         self.add_message(_message, 'success')
         return self.redirect_to('login')
     _message = 'Your email address was not found. Please try another or <a href="/register">create an account</a>.'
     self.add_message(_message, 'error')
     return self.redirect_to('password-reset')
开发者ID:Joelone,项目名称:gae-boilerplate,代码行数:17,代码来源:handlers.py

示例8: user

# 需要导入模块: from webapp2_extras.appengine.auth.models import User [as 别名]
# 或者: from webapp2_extras.appengine.auth.models.User import get_by_auth_id [as 别名]
 def user(self):
     auth_id = self.session.get('user', None)
     if auth_id:
         return User.get_by_auth_id(auth_id)
开发者ID:carlitux,项目名称:test-gae,代码行数:6,代码来源:main.py


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