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


Python User.get_cached方法代码示例

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


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

示例1: _deserialize

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get_cached [as 别名]
    def _deserialize(self):
        """Look up the User objects from stored session ids and store them"""
        raw_data = self.request.session[self._session_key()]

        # If this is an older session, discard it and create a new default one
        if self._is_old_session(raw_data):
            self._create()
            raw_data = self.request.session[self._session_key()]

        self.participants = [
            Participant(
                signup_session=self,
                id=p['id'],
                user=User.get_cached(id=p['user_id']) if p['user_id'] is not None else None,
                first_name=p['first_name'],
                last_name=p['last_name'],
                email=p['email'],
                phone=p['phone'],
                birth_date=datetime.strptime(p['birth_date'], "%Y-%m-%d").date() if p['birth_date'] is not None else None,
                state=p['state'],
                use_parent_contact_info=p['use_parent_contact_info'],
                use_signee_contact_info=p['use_signee_contact_info'],
                discount_code=p['discount_code'],
                signee_relation=p['signee_relation'],
                answers=p['answers'],
                extras=p['extras'],
            )
            for p in raw_data['participants']
        ]
        self.comment = raw_data['comment']
        self.extras = raw_data['extras']
        self.extras_defaults_set = raw_data['extras_defaults_set']
        self.participate_together = raw_data['participate_together']
开发者ID:Turistforeningen,项目名称:sherpa,代码行数:35,代码来源:signup_session.py

示例2: get_user

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get_cached [as 别名]
 def get_user(self, user_id):
     try:
         # Important note: This method should *not* return a cached user
         # object on authentication - just for subsequent requests (so that
         # we avoid an extra DB user query for each request). Clearing the
         # user cache when `authenticate` is called should be sufficient to
         # achieve this.
         return User.get_cached(
             id=user_id,
             include_expired=True,
         )
     except User.DoesNotExist:
         return None
开发者ID:Turistforeningen,项目名称:sherpa,代码行数:15,代码来源:auth_backends.py

示例3: _deserialize

# 需要导入模块: from user.models import User [as 别名]
# 或者: from user.models.User import get_cached [as 别名]
    def _deserialize(self):
        """Look up the User objects from stored session ids and store them"""
        raw_data = self.request.session[self._session_key()]

        # If this is an older session, discard it and create a new default one
        if self._is_old_session(raw_data):
            self._create()
            raw_data = self.request.session[self._session_key()]

        self.participants = [
            Participant(
                signup_session=self,
                user=User.get_cached(id=p['id']),
                state=p['state'],
                use_guardian_contact_info=p['use_guardian_contact_info'],
                discount_code=p['discount_code'],
            )
            for p in raw_data['participants']
        ]
        self.comment = raw_data['comment']
        self.participate_together = raw_data['participate_together']
开发者ID:,项目名称:,代码行数:23,代码来源:


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