[Zope] Zope and Objects

Max M maxm@mxm.dk
Wed, 26 Mar 2003 11:05:37 +0100


Jeff Childers wrote:

> I'm starting to get the "big picture" but I'm still a little fuzzy on 
> the details, particularly about objects and the ZODB. I'm hoping that 
> someone can give me some brief pointers to where the answers the these 
> questions lie. I have read a *bunch* of Zope doc and I'm pretty handy 
> with Python.
>
> 1) Where are data object classes defined in Zope?


> I get the persistent object thing. Very cool. So let's say I want to 
> write a billing system. I have customer objects, invoice objects, and 
> payment objects. [ Customer [ Invoices [Payments] ] ].
>
> a) Where do I put the code that defines each custom class? Scripts 
> seem to be for def-functions. Do I have to put this outside Zope? 



You need to write a Zope product i Python to do these things. There is a 
good overview here:

http://www.zope.org/Documentation/comp_tut

> b) Do I use ZCatalogs to 'index' my objects so I can query them 
> similar to SQL? If so, how/where do I add my custom classes to the 
> ZCatalog? 



Your classes should just subclass "CatalogPathAware" and they are 
automatically catalog aware. If you use this tool to write your 
products, they are so automatically:

http://www.zope.org/Members/maxm/HowTo/easyProduct

> 2) How do I instantiate and persist (through the session) a particular 
> instance of the class from the ZODB (i.e. a certain customer)? 



When you write your products, you also write a "constructor" function, 
which does it for you.

regards Max M