[Zope-dev] [Partial Solution] Re: Establishing root objects in ZODB under Zope

Ross Boylan RossBoylan@stanfordalumni.org
Wed, 23 Jan 2002 22:23:57 -0800


At 09:37 PM 1/23/02 -0800, Ross Boylan wrote:
>I have some data that will not naturally live as an item in a folder.  If 
>I'm using Zope, how do I establish a root for it?  The ZODB docs talk 
>about how to handle a free-standing database, but I don't see info about 
>how to use the one that Zope has already set up.  I recall there's some 
>way to get a handle to the open database, but I don't recall exactly 
>what.  Can anybody help me out?

Continuing to  talk to myself.... I finally found some old notes.  For the 
record (unless things have changed)
conn = aPersistentObject._p_jar
will retrieve the connection.  One can then get the root with
conn.root()

Thanks to Jim Fulton who originally explained this to me.

I'm still wondering about class variables being persistent and the 
efficiency of PersistentList, if anyone has any comments.


>If I use a class variable, will that be persisted automatically, e.g.
>class MyManager(Persistence.Persistent):
>         MyClassVariable = SomePersistentClass()
>         .....
>? (Actually, I'm not sure if it matters whether MyManager is a subclass of 
>Persistent).
>
>Or, if it is not automatically persistent, is there anything I can do to 
>make it persistent so that it will obey the transaction boundaries coming 
>from web requests?
>
>Final question, which is distinct from the root objects issue: if I use 
>Zope's Persistent List, will that avoid the problem of faulting in the 
>whole list if I don't need it?  I am looking for a good way to keep a 
>record of transactions.  ZODB's raw transaction recording is probably not 
>quite right since it has the wrong granularity, it mixes a lot of 
>unrelated transactions (it's only some I want), and I think it can get 
>zapped if I do various database compactions and cleanups.
>
>Thanks.
>
>
>_______________________________________________
>Zope-Dev maillist  -  Zope-Dev@zope.org
>http://lists.zope.org/mailman/listinfo/zope-dev
>**  No cross posts or HTML encoding!  **
>(Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
>http://lists.zope.org/mailman/listinfo/zope )