restore object class after saving it; and make sure identities are added in the right directory

This commit is contained in:
Frédéric Péters 2008-12-15 12:50:35 +01:00
parent 2f4005ffe5
commit a420ba9a31
1 changed files with 10 additions and 0 deletions

View File

@ -63,6 +63,14 @@ class InheritingIdentityStore(authentic.identities.IdentitiesStoreStorage):
t.__class__ = self.identity_class
return t
def add(self, identity):
# make sure identity class is the correct one, and get a new id
# appropriate for that class
identity.__class__ = self.identity_class
identity.id = identity.get_new_id()
authentic.identities.IdentitiesStoreStorage.add(self, identity)
class ParthenayIdentityStore(InheritingIdentityStore):
def get_identity_for_account(self, account):
@ -98,8 +106,10 @@ def get_collectivity_identity_class(collectivity_id):
if not os.path.exists(objects_dir):
os.mkdir(objects_dir)
self._filename = os.path.join(self._names, fix_key(self.id))
old_class = self.__class__
self.__class__ = authentic.identities.Identity
authentic.identities.Identity.store(self)
self.__class__ = old_class
return CollectivityIdentity