On 26.02.19 23:28, Gerhard Schmidt wrote: > Am 25.02.2019 um 10:51 schrieb Jens W. Klein: >> On 24.02.19 08:48, Gerhard Schmidt wrote:> Hi, [...]>>> Is there a way to test if a persistent object would be saved when the >>> transaction is committed. >> >> _p_changed is meant as a trigger, but it is not meant to read a status. >> Triggering _p_changed joins the object to a transaction manager which >> then on commit saves the object. > > In the normal code I don't read it, but for testing purposes it would be > quite handy. > >> What your're looking for is probably _p_status which is "saved" or >> "unsaved". > > it's always 'unsaved' while testing, because all objects are brand new > as the database is new for every test. Even after calling > transaction.commit() it's still unsaved. Is there a way to query the > transaction manager if a object is in the to be saved list.
Sorry, I am not sure what it means in testing and if the bahvior here is different. >> For dicts/lists Thierry is right, better use >> PersistentList/PersistentDict in order to not to have to trigger >> _p_changed manually. > > For most purposes I use PersistenList/Dict, but first there is no > PersistentSet. PersistenList and PeristentDict (especial PeristentDicts > in a PersistentList) tend to fill the ZODB with many small objects and > remove other from the cache. So I use the not persistent ones when they > don't change often (most of the Time never) but even code that called > once a month or once a year has to be tested. And when _p_changed is not > used often the chance of forgetting increases and testing it is rather > useful. You may want touse the BTrees package https://pypi.org/project/BTrees/ where different kinds of persistent BTrees and persistent Sets are implemented in a very efficient way (also using C-Extension). Documentation at https://btrees.readthedocs.io/en/latest/ hth Jens -- Klein & Partner KG, member of BlueDynamics Alliance -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/q5qnt6%2465ip%241%40blaine.gmane.org. For more options, visit https://groups.google.com/d/optout.
