Maric Michaud schrieb: > robert rottermann a écrit : > > I do not see any reference to mark_changed > > you have to call it before any transaction.commit() to tell the zope > transaction > > machinery that it has to commit you changes also. > > robert > > > > In fact, what I understood is that zope.sqlalchemy, by default, bypasses > the commit if status is not manually set as 'changed' (see the docstring > I quoted in my previous mail). The alternative is to build the > SessionExtension with initial_state == STATUS_INVALIDATED. > > My point is that it should be the default for a DA, as it is intended to > be used mainly by zsql methods which doesn't do nothing to the > transaction state. > > Maybe I wasn't clear but the patch works well with my existing zsql code. > it is a longtime that i worked with zsql methods. however I think the difference is, that zsql handles transactions itself. it wraps every zqls method in a start/end transaction. pair.
this is similarly done by zope.sqlalchemy. but it will only commit, when you tell it that the session is dirty by calling mark_changed import transaction from zope.sqlalchemy import mark_changed. here is how I use it def addKtyp(self, form, commit=1): """ create a new ktyp return id of that ktyp """ session = self.getSession() ... if values: ... if not ktyp: ... session.add(ktyp) # only mark the session, do not yet commit self.mark_changed() if commit: transaction.commit() # we only know the id after a commit !!! ktyp_id = ktyp.ktypid return ktyp_id robert _______________________________________________ Zope maillist - Zope@zope.org http://mail.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://mail.zope.org/mailman/listinfo/zope-announce http://mail.zope.org/mailman/listinfo/zope-dev )