コード例 #1
0
ファイル: main.py プロジェクト: Atrac613/mocomo.co
 def get(self):
     from csrffilter import CSRFFilter
     from pubsubhubbub import pubSubHubbub
     
     user = users.get_current_user()
     
     user_prefs_query = UserPrefs.all()
     user_prefs_query.filter("google_id =", user)
     user_prefs = user_prefs_query.get()
     
     mode = self.request.get('mode')
     
     if mode == 'add_twitter_account':
         self.redirect('/oauth/twitter/login')
         
     elif mode == 'delete_twitter_account':
         if user_prefs.oauth_access_token_key:
             oauth_access_token_query = OAuthAccessToken.get_by_key_name(user_prefs.oauth_access_token_key.key().name())
             oauth_access_token_query.delete()
             user_prefs.oauth_access_token_key = None
             user_prefs.put()
             
     elif mode == 'enable_sync':
         hub = pubSubHubbub(self, user)
         
         subscribe_feed = 'http://buzz.googleapis.com/feeds/%s/public/posted' % user.nickname()
         hub.add_feed(subscribe_feed)
         
         user_prefs.callback_key = hub.callback_key
         user_prefs.put()
         
     elif mode == 'disable_sync':
         hub = pubSubHubbub(self, user)
         
         subscribe_feed = 'http://buzz.googleapis.com/feeds/%s/public/posted' % user.nickname()
         hub.remove_feed(subscribe_feed)
     
     template_values = {
         'nickname' : user.nickname(),
         'user_prefs': user_prefs,
         }
     
     path = os.path.join(os.path.dirname(__file__), 'templates/config.html')
     html = template.render(path, template_values)
     self.response.out.write(CSRFFilter(self, user).insertCSRFToken(html))
コード例 #2
0
ファイル: main.py プロジェクト: Atrac613/mocomo.co
 def post(self, callback_key):
     from pubsubhubbub import pubSubHubbub
     hub = pubSubHubbub(self, None, callback_key)
     self.response.out.write(hub.receive_feeds('POST'))