Merge branch 'master' of https://schwann.lnvpn.de/haraldwolff/python-objectbroker
commit
13bf9c6ad3
|
@ -121,6 +121,9 @@ class AquisitionProxy:
|
|||
return v
|
||||
|
||||
def __setattr__(self,name,value):
|
||||
if name == "":
|
||||
raise AttributeError("attributes need to have a name!")
|
||||
|
||||
setattr( object.__getattribute__( self, "_o"), name, value )
|
||||
|
||||
def __delattr__(self,name):
|
||||
|
|
|
@ -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
|
||||
|
@ -78,9 +80,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