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

Brad Allen brad at allendev.com
Wed Nov 30 21:28:22 EST 2005



At 5:01 PM -0700 11/30/05, Duncan McGreggor wrote:
>z3 utilizes a component-based approach - both in the way that it was 
>built and in the way that applications are built using it. To "get a 
>hold" of certain components, you use various useful functions that 
>are provided in the zapi (many of which come from the components 
>package). One of the most common ways of getting a hold of an object 
>or object type is by interface lookup.

Ok, suppose there is a ZPT Page object located in the ZMI/ZODB in the 
following folder path:

	/SiteName/UserContent/Articles/IntroText

To "get ahold" of the object from within Python...by that I mean bind 
a variable name to an object...you say I should use an interface 
lookup. I don't get it. I've seen how to validate whether an object 
implements an interface, or whether an interfaces is providedBy an 
object, but I don't know how to lookup an object via an interface.

In the case of a ZPT, it implements a lot of different interfaces :

	zope.app.zptpage.interfaces.IZPTPage
	zope.app.zptpage.interfaces.IRenderZPTPage
	zope.app.publication.interfaces.IFileContent
	zope.app.annotation.interfaces.IAttributeAnnotatable
	zope.pagetemplate.interfaces.IPageTemplateSubclassing
	persistent.interfaces.IPersistent
	zope.app.container.interfaces.IContained

Which one would I pick to use for a lookup? And if I picked the right 
one, wouldn't I get back a list of objects, rather than the specific 
one I want?

I guess I'm asking if there is a function that will allow me to do this:

introText = getObject ('/SiteName/UserContent/Articles/IntroText')

 From there, I'd expect to be able to rename the object, move it to a 
different directory, delete it, copy it, put it inside another 
object, change attributes, call methods on it, etc.

Am I misguided in wanting this? I am just wondering how to get at 
user generated data, manipulate it, export it, etc. I've seen how to 
get at objects in the ZODB via TALES expressions, but all I can with 
that is display it, right?



More information about the Zope3-users mailing list