コード例 #1
0
ファイル: account.py プロジェクト: LeonardoXavier/f1
    def verify(self, *args, **kw):
        provider = request.params.get('provider')
        service = get_provider(provider)

        auth = service.responder()
        try:
            user = auth.verify()
            account = user['profile']['accounts'][0]
            if not user.get('oauth_token') and not user.get('oauth_token_secret'):
                raise Exception('Unable to get OAUTH access')
            acct = self._get_or_create_account(provider, account['userid'], account['username'])
            acct.profile = user['profile']
            acct.oauth_token = user.get('oauth_token', None)
            if 'oauth_token_secret' in user:
                acct.oauth_token_secret = user['oauth_token_secret']
            acct.updated = UTCDateTime.now()
            try:
                Session.commit()
            except UnicodeEncodeError, e:
                log.exception("***** UnicodeEncodeError! %r: %r: %r %r" % (acct.domain, acct.userid, acct.username,acct.json_attributes,))
                raise e
            # XXX argh, this is also done in get_or_create above, but we have to
            # ensure we have the updated data
            session[acct.key] = acct.to_dict()
            session.save()
コード例 #2
0
ファイル: links.py プロジェクト: jrburke/f1
 def get_or_create(longurl, author=None):
     try:
         return Session.query(Link).filter_by(long_url=longurl).one()
     except NoResultFound:
         l = Link()
         l.long_url = longurl
         l.userkey = author
         Session.add(l)
         if asbool(config.get('test_shortener')):
             # add and commit to get the id, then shorten
             Session.commit()
             Session.flush()
         l.shorten()
         Session.commit()
         return l
コード例 #3
0
ファイル: account.py プロジェクト: jrburke/f1
    def verify(self, *args, **kw):
        provider = session.pop('oauth_provider')
        session.save()
        service = get_provider(provider)

        auth = service.responder()
        try:
            user = auth.verify()
            account = user['profile']['accounts'][0]
    
            acct = self._get_or_create_account(provider, account['userid'], account['username'])
            acct.profile = user['profile']
            acct.oauth_token = user.get('oauth_token', None)
            if 'oauth_token_secret' in user:
                acct.oauth_token_secret = user['oauth_token_secret']
            acct.updated = UTCDateTime.now()
            Session.commit()
            # XXX argh, this is also done in get_or_create above, but we have to
            # ensure we have the updated data
            session[acct.key] = acct.to_dict()
            session.save()
        except AccessException, e:
            self._redirectException(e)