Schema change to secondary ids are stored with their class, not just their bare id.
This commit is contained in:
parent
bd8a6894e2
commit
0129c2a2c3
|
@ -60,12 +60,12 @@ class Database( object ):
|
||||||
|
|
||||||
object_id = unicode( obj.object_id ).encode( "utf8" )
|
object_id = unicode( obj.object_id ).encode( "utf8" )
|
||||||
revision_id = unicode( obj.revision_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
|
# update the cache with this saved object
|
||||||
self.__cache[ object_id ] = obj
|
self.__cache[ object_id ] = obj
|
||||||
self.__cache[ revision_id ] = copy( obj )
|
self.__cache[ revision_id ] = copy( obj )
|
||||||
if obj.secondary_id:
|
if secondary_id:
|
||||||
self.__cache[ secondary_id ] = obj
|
self.__cache[ secondary_id ] = obj
|
||||||
|
|
||||||
# set the pickler up to save persistent ids for every object except for the obj passed in, which
|
# 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 )
|
self.__db.put( revision_id, pickled )
|
||||||
|
|
||||||
# write the pickled object id (only) to the database under its secondary id
|
# write the pickled object id (only) to the database under its secondary id
|
||||||
if obj.secondary_id:
|
if secondary_id:
|
||||||
buffer = StringIO()
|
buffer = StringIO()
|
||||||
pickler = cPickle.Pickler( buffer, protocol = -1 )
|
pickler = cPickle.Pickler( buffer, protocol = -1 )
|
||||||
pickler.persistent_id = lambda o: self.__persistent_id( o )
|
pickler.persistent_id = lambda o: self.__persistent_id( o )
|
||||||
|
|
|
@ -378,7 +378,7 @@ class Notebooks( object ):
|
||||||
@async
|
@async
|
||||||
def check_access( self, notebook_id, user_id, callback ):
|
def check_access( self, notebook_id, user_id, callback ):
|
||||||
# check if the anonymous user has access to this notebook
|
# 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 )
|
anonymous = ( yield Scheduler.SLEEP )
|
||||||
|
|
||||||
access = False
|
access = False
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Users( object ):
|
||||||
if password != password_repeat:
|
if password != password_repeat:
|
||||||
raise Signup_error( u"The passwords you entered do not match. Please try again." )
|
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 )
|
user = ( yield Scheduler.SLEEP )
|
||||||
|
|
||||||
if user is not None:
|
if user is not None:
|
||||||
|
@ -166,7 +166,7 @@ class Users( object ):
|
||||||
login_button = unicode,
|
login_button = unicode,
|
||||||
)
|
)
|
||||||
def login( self, username, password, login_button ):
|
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 )
|
user = ( yield Scheduler.SLEEP )
|
||||||
|
|
||||||
if user is None or user.check_password( password ) is False:
|
if user is None or user.check_password( password ) is False:
|
||||||
|
@ -205,7 +205,7 @@ class Users( object ):
|
||||||
)
|
)
|
||||||
def current( self, user_id ):
|
def current( self, user_id ):
|
||||||
# if there's no logged-in user, default to the anonymous user
|
# 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 )
|
user = ( yield Scheduler.SLEEP )
|
||||||
|
|
||||||
if not user:
|
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
|
# in addition to this user's own notebooks, add to that list the anonymous user's notebooks
|
||||||
if user_id:
|
if user_id:
|
||||||
self.__database.load( u"anonymous", self.__scheduler.thread )
|
self.__database.load( u"User anonymous", self.__scheduler.thread )
|
||||||
anonymous = ( yield Scheduler.SLEEP )
|
anonymous = ( yield Scheduler.SLEEP )
|
||||||
notebooks = anonymous.notebooks
|
notebooks = anonymous.notebooks
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -17,6 +17,9 @@ class Persistent( object ):
|
||||||
def make_revision_id( object_id, revision ):
|
def make_revision_id( object_id, revision ):
|
||||||
return "%s %s" % ( 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 ):
|
def to_dict( self ):
|
||||||
return dict(
|
return dict(
|
||||||
object_id = self.__object_id,
|
object_id = self.__object_id,
|
||||||
|
|
Reference in New Issue