[TransWarp] QueryDM deactivates new objects

Phillip J. Eby pje at telecommunity.com
Tue Apr 29 11:36:38 EDT 2003

At 06:01 PM 4/29/03 +0400, Oleg Broytmann wrote:
>    I have a problem using QueryDM data manager. I tried to get an object by
>ID: row = MyDM[id] - and got the object. The problem is that its
>__getitem__ calls ob._p_deactivate(), and this destroyed my object.

I'm not sure I follow you.  Your '_ghost()' method is *supposed* to return 
an object that has no state.  So _p_deactivate() should effectively be a no-op.

>    Does QueryDM work in assumption that initialy the object must be "empty"
>(for whatever value of "empty")?

Yes.  It's the job of the '_load()' method to activate them, unless it is a 
newly created object, in which case '_defaultState()' (for an EntityDM) 
creates the initial state.

>    I am trying to use PersistentDict as defaultClass, and _p_deactivate()
>destroys its "data" field (from UserDict).

But it shouldn't have any data, until it's loaded by your '_load()' 
method.  Please note that QueryDM is intended for read-only *queries*.  If 
you want a DM that allows manipulating objects, you need an EntityDM, and 
you create new objects with EntityDM.newItem().

More information about the PEAK mailing list