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


Python UserInfo.key方法代码示例

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


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

示例1: get

# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import key [as 别名]
 def get(self):
   user = users.get_current_user()
   if user:
     auth_token = self.request.get("oauth_token")
     if auth_token:
       credentials = constants.get_client().get_credentials(auth_token)
       old_userinfos = UserInfo.all().filter('user =', user).fetch(500)
       db.delete(old_userinfos)
       userinfo = UserInfo(user = user, token = credentials['token'], secret = credentials['secret'], is_ready=False, is_authorized=True, last_checkin=0, last_updated=datetime.now(), color_scheme='fire', level_max=int(constants.level_const), checkin_count=0, venue_count=0)
       fetch_foursquare_data.update_user_info(userinfo)
       fetch_foursquare_data.fetch_and_store_checkins(userinfo, limit=10)
       taskqueue.add(url='/fetch_foursquare_data/all_for_user/%s' % userinfo.key())#, queue_name='initial-checkin-fetching')
       self.redirect("/")
     else:
       self.redirect(constants.get_client().get_authorization_url())
   else:
     self.redirect(users.create_login_url(self.request.uri))
开发者ID:ubilabs,项目名称:where-do-you-go,代码行数:19,代码来源:handlers.py

示例2: get

# 需要导入模块: from models import UserInfo [as 别名]
# 或者: from models.UserInfo import key [as 别名]
  def get(self):
    user = users.get_current_user()
    if user:
      oauth_token = self.request.get("oauth_token")

      def get_new_fs_and_credentials():
        oauth_token, oauth_secret = constants.get_oauth_strings()
        credentials = foursquare.OAuthCredentials(oauth_token, oauth_secret)
        fs = foursquare.Foursquare(credentials)
        return fs, credentials

      if oauth_token:
        old_userinfos = UserInfo.all().filter('user =', user).fetch(500)
        db.delete(old_userinfos)
        fs, credentials = get_new_fs_and_credentials()
        apptoken = AppToken.all().filter('token =', oauth_token).get()
        
        try:
          user_token = fs.access_token(oauth.OAuthToken(apptoken.token, apptoken.secret))
          credentials.set_access_token(user_token)
          userinfo = UserInfo(user = user, token = credentials.access_token.key, secret = credentials.access_token.secret, is_ready=False, is_authorized=True, last_checkin=0, last_updated=datetime.now(), color_scheme='fire', level_max=int(constants.level_const), checkin_count=0, venue_count=0)
        except DownloadError, err:
          if str(err).find('ApplicationError: 5') >= 0:
            pass # if something bad happens on OAuth, then it currently just redirects to the signup page
                 #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
          else:
            raise err
        try:
          fetch_foursquare_data.update_user_info(userinfo)
          fetch_foursquare_data.fetch_and_store_checkins(userinfo, limit=10)
          taskqueue.add(url='/fetch_foursquare_data/all_for_user/%s' % userinfo.key())
        except foursquare.FoursquareRemoteException, err:
          if str(err).find('403 Forbidden') >= 0:
            pass # if a user tries to sign up while my app is blocked, then it currently just redirects to the signup page
                 #TODO find a better way to handle this case, but it's not clear there is a simple way to do it without messing up a bunch of code
          else:
            raise err
        except DownloadError:
          pass #TODO make this better, but I'd rather throw the user back to the main page to try again than show the user an error.
开发者ID:mrfelcio,项目名称:where-do-you-go,代码行数:41,代码来源:handlers.py


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