Add NOPERSIST support
parent
6883cb203d
commit
3d620466e7
|
@ -30,12 +30,14 @@ def obj_getstate(o):
|
|||
state["pfields"] = {}
|
||||
state["pvalues"] = {}
|
||||
|
||||
nopersistence = getattr(o,"NOPERSIST",())
|
||||
|
||||
|
||||
d = object.__getattribute__(o, "__dict__")
|
||||
for n in d.keys():
|
||||
a = getattr( o, n )
|
||||
if (not isinstance( a, collections.Callable)) or isinstance( a, object ):
|
||||
if (isinstance( a, NoPersistence)):
|
||||
if (isinstance( a, NoPersistence)) or (n in nopersistence):
|
||||
state["fields"][n] = None
|
||||
elif (isinstance( a, Persistence)):
|
||||
state["pvalues"][n] = a
|
||||
|
@ -77,9 +79,12 @@ class ObjectBroker:
|
|||
for n in list( self.__unsaved.keys() ):
|
||||
s = self.__unsaved[n]
|
||||
s["pvalues"] = None
|
||||
self.__store[ s["pid"] ] = pickle.dumps(s)
|
||||
del self.__unsaved[n]
|
||||
|
||||
try:
|
||||
self.__store[ s["pid"] ] = pickle.dumps(s)
|
||||
del self.__unsaved[n]
|
||||
except AttributeError as ae:
|
||||
log("AttributeError while storing object: %s" % (s,))
|
||||
|
||||
return state["pid"]
|
||||
|
||||
def load(self,persistence_id):
|
||||
|
|
Loading…
Reference in New Issue