[Zope-dev] ZPatterns AttributeProvider question
Christian Scholz
cs@comlounge.net
Sun, 22 Apr 2001 20:29:33 +0200
Hi!
A little update..
Actually I was mistaken and SetAttributeFor() is called. Just _objectChanged()
is not called in that case.. and thus my attributes are not stored to the database.
Also commit() is not called at all in this case. It get's called once when the
subtranscation is committed but not after some data has changed (which happens
after that).
Printing _v_status_ in SetAttributeFor() also gives me "Changed", thus this seems
right.
Maybe some more code will help (just the important pieces):
def _objectAdded(self,client):
""" store cached data in database """
... here we do an sql query to insert things in database ...
def _objectChanged(self,client):
""" store cached data in database """
... here we do an sql query to update things in database ...
def _objectAdding(self,client,
_tmap={ None:AddedStatus,
DeletedStatus:ChangedStatus,
ChangedStatus:AddedStatus
}
):
t = client._getTokenFor(self)
s = t.status
t.status = _tmap.get(s,s)
# we need to do a commit here in order to store the record into the database!
# and we need to have it stored as an AttributeFor() of the primary key will
# return None otherwise (as this also just makes a query).
client.commitSubtransaction()
def _SetAttributeFor(self,client,name,value):
"""Set the attribute and return true if successful"""
# attribs stores the attributes we care about
if name in self._attribs.keys():
client._getCache()[name]=value
client.__dict__[name]=value;
client._p_changed = 1
return 1
return None
So _objectChanging() is not overridden, the rest I have ommitted..
So as you also can see I already do a subtransaction commit but it does
not seem to help for this problem..
regards,
Christian
PS: It might also be that I am simply blind ;-) But somehow ZPatterns always confuses me,
especially the inner workings ;-)
--
COM.lounge http://comlounge.net/
communication & design info@comlounge.net