witten
/
luminotes
Archived
1
0
Fork 0

Schema change to secondary ids are stored with their class, not just their bare id.

This commit is contained in:
Dan Helfman 2007-07-20 20:05:02 +00:00
parent bd8a6894e2
commit 0129c2a2c3
4 changed files with 11 additions and 8 deletions

View File

@ -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 )

View File

@ -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

View File

@ -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:

View File

@ -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,