[Zope3-Users] Direct ZODB access in a Zope3 instance

Brad Allen brad at allendev.com
Wed Nov 30 17:07:14 EST 2005


I'm copying some discussion here from another thread called "need guidance".

At 12:33 PM -0700 11/30/05, Duncan McGreggor wrote:

>>Hmm, again, I think you *might* want to stay away from an approach 
>>that interacts directly with the ZODB. Unless you're not using 
>>z3/Zope 2...

Brad Allen replied:

>I didn't see this posting until after I started a new thread called
>"Direct ZODB access in a Zope3 instance". So, why is it a bad
>idea?


Duncan McGreggor replied:
>Well, it's a great idea if your application is non-zope python with 
>a need for "versioned" storage.
>
>It's not such a good idea if your application is a zope app because 
>those app servers do so much of the work for you, with many years of 
>honing put into them.
>
>The best thing to do is learn how to use the app server/framework 
>such that your work is minimized (both short- and long-term) and 
>such that the final product is a stable as possible (building on 
>prior, tested, and proven work).
>
>Direct access in a z3 app is usually made for debugging purposes, 
>and used with the pdb, can be very effective for hunting down and 
>solving issues.

Ok, so using the app/server framework to read and write from ZODB is 
the way to go. I'm trying to understand exactly how that works. The 
books show how to register components using ZCML, but that doesn't 
create instances, right? As far as I can remember seeing, a human has 
to click something in the ZMI Add menu to create an instance in the 
ZODB.

Meanwhile, the chapter in Philikon's book on persistence just shows 
how to create persistent classes and talks about how they work, but 
it doesn't say anything about how to insert an instance into ZODB.

I guess this whole topic wasn't really explained in the books, unless 
I missed something (quite likely). An earlier posting from Duncan 
gives me a hint:

At 2:44 AM -0700 11/30/05, Duncan McGreggor wrote:
>Yeah, I think you're looking for code-based content addition -- is 
>that right? If so, you're going to want to spend some time looking 
>at zope.app.zapi (a lot of which comes from zope.component). In 
>particular, the createObject() function. Take a look at those 
>projects I mentioned above... and other folks may have good 
>suggestions for code examples on site creation and pre-population of 
>content

The createObject() function documentation doesn't explicitly say it's 
creating an object in the ZODB, either in the Philikon book or in the 
API documentation at ++apidoc++.  It might be nice to have something 
about that mentioned...

How do I actually get a handle to an object in the ZODB, so I can 
manipulate attributes?





More information about the Zope3-users mailing list