How to remove from webapp2_extras.appengine.auth.models.Unique?

I am using webapp2_extras.appengine.auth in my project and creates 3 tables in datastore: User, UserToken and Unique. Everything is fine and works as it should ...

My question is, how can I remove something from Unique?

+3


source to share


1 answer


I was unable to find what I need to remove because the unique model does not contain any user references. Here's the solution (with reference to the docs):



from google.appengine.ext import ndb
from webapp2_extras import auth

class SomeUserHandler():
  def forget_user(self):
    auth = auth.get_auth()
    user_dict = auth.get_user_by_session()
    user = auth.store.user_model.get_by_id(user_dict['user_id'])

    # from webapp2_extras.appengine.auth.models.User
    # http://webapp-improved.appspot.com/_modules/webapp2_extras/appengine/auth/models.html#User
    # 
    # def add_auth_id(self, auth_id):
    #   ...
    #   unique = '%s.auth_id:%s' % (self.__class__.__name__, auth_id)
    #   ...
    Unique.delete_multi( map(lambda s: 'User.auth_id:' + s, user.auth_ids) )

      

+4


source







All Articles