diff --git a/controller/Database.py b/controller/Database.py index 0fb3a33..c6ea4b7 100644 --- a/controller/Database.py +++ b/controller/Database.py @@ -60,12 +60,12 @@ class Database( object ): object_id = unicode( obj.object_id ).encode( "utf8" ) revision_id = unicode( obj.revision_id() ).encode( "utf8" ) - secondary_id = obj.secondary_id and unicode( obj.secondary_id ).encode( "utf8" ) or None + secondary_id = obj.secondary_id and unicode( obj.full_secondary_id() ).encode( "utf8" ) or None # update the cache with this saved object self.__cache[ object_id ] = obj self.__cache[ revision_id ] = copy( obj ) - if obj.secondary_id: + if secondary_id: self.__cache[ secondary_id ] = obj # set the pickler up to save persistent ids for every object except for the obj passed in, which @@ -81,7 +81,7 @@ class Database( object ): self.__db.put( revision_id, pickled ) # write the pickled object id (only) to the database under its secondary id - if obj.secondary_id: + if secondary_id: buffer = StringIO() pickler = cPickle.Pickler( buffer, protocol = -1 ) pickler.persistent_id = lambda o: self.__persistent_id( o ) diff --git a/controller/Notebooks.py b/controller/Notebooks.py index 756b19b..1389707 100644 --- a/controller/Notebooks.py +++ b/controller/Notebooks.py @@ -378,7 +378,7 @@ class Notebooks( object ): @async def check_access( self, notebook_id, user_id, callback ): # check if the anonymous user has access to this notebook - self.__database.load( u"anonymous", self.__scheduler.thread ) + self.__database.load( u"User anonymous", self.__scheduler.thread ) anonymous = ( yield Scheduler.SLEEP ) access = False diff --git a/controller/Users.py b/controller/Users.py index bb8f58f..9d52b85 100644 --- a/controller/Users.py +++ b/controller/Users.py @@ -123,7 +123,7 @@ class Users( object ): if password != password_repeat: raise Signup_error( u"The passwords you entered do not match. Please try again." ) - self.__database.load( username, self.__scheduler.thread ) + self.__database.load( "User %s" % username, self.__scheduler.thread ) user = ( yield Scheduler.SLEEP ) if user is not None: @@ -166,7 +166,7 @@ class Users( object ): login_button = unicode, ) def login( self, username, password, login_button ): - self.__database.load( username, self.__scheduler.thread ) + self.__database.load( "User %s" % username, self.__scheduler.thread ) user = ( yield Scheduler.SLEEP ) if user is None or user.check_password( password ) is False: @@ -205,7 +205,7 @@ class Users( object ): ) def current( self, user_id ): # if there's no logged-in user, default to the anonymous user - self.__database.load( user_id or u"anonymous", self.__scheduler.thread ) + self.__database.load( user_id or u"User anonymous", self.__scheduler.thread ) user = ( yield Scheduler.SLEEP ) if not user: @@ -217,7 +217,7 @@ class Users( object ): # in addition to this user's own notebooks, add to that list the anonymous user's notebooks if user_id: - self.__database.load( u"anonymous", self.__scheduler.thread ) + self.__database.load( u"User anonymous", self.__scheduler.thread ) anonymous = ( yield Scheduler.SLEEP ) notebooks = anonymous.notebooks else: diff --git a/model/Persistent.py b/model/Persistent.py index 27c21de..d344b22 100644 --- a/model/Persistent.py +++ b/model/Persistent.py @@ -17,6 +17,9 @@ class Persistent( object ): def make_revision_id( object_id, revision ): return "%s %s" % ( object_id, revision ) + def full_secondary_id( self ): + return "%s %s" % ( type( self ).__name__, self.secondary_id ) + def to_dict( self ): return dict( object_id = self.__object_id,