def on_profile_response(self, twitter_user):
        """Handles user profile request response."""
        user_id = None
        current_user = User.objects(service='twitter', nick=twitter_user['username']).first()
        if current_user != None:
            user_id = unicode(current_user.id)
            logging.info('Twitter user "%s" already signed up.' % (twitter_user['username'], ))
            if len(current_user.auth) == 0 or current_user.auth['key'] != twitter_user['access_token']['key']:
                current_user.auth = twitter_user['access_token']
                
                try:
                    current_user.save()
                except:
                    logging.exception('Could not update Twitter user auth token.')
                    self.send_error
        else:
            user = User(service='twitter', nick=twitter_user['username'], url='http://twitter.com/' + twitter_user['username'], avatar_url=twitter_user['profile_image_url'])
            user.auth = twitter_user['access_token']
            
            logging.info((twitter_user['username'], ) % 'Saving Twitter user "%s".')
            try:
                user.save()
            except:
                logging.exception('Failed to save user in DB.')
                self.send_error()
                
            user_id = unicode(user.id)
            
        self.set_secure_cookie('user_id', user_id, expires_days=365)
        self.redirect('/#publish')
dataset/ETHPy150Open tomekwojcik/iheartgit/iheartgit/handlers/oauth.py/TwitterHandler.on_profile_response/swapped operands of `%`