On Thursday 27 July 2006 05:17, Carlo Cardelli wrote:
> - how do I get all my Customers instances? The Customer class is marked
> as 'Persistent' and 'IContentType'.
You have several choices:
1. Register your customer object as a utility and then do utility lookups. In
this case you can reuse code in zope.app.component.vocabulary.
2. You probably have a convention where to find customers, like a
"CustomerContainer". You can setup your application to easily look up this
container to get the entries.
> - how do I connect them to the vocabulary in a way to store a
> 'reference' to the object and not, say, only its custName?
See zope.app.component.vocabulary; it provides one example.
> I have to fill 2 slots in the following:
> def CustomerVocabulary():
> allterms = 
> for customer in [ ...What goes here...? ]:
> oneTerm = zope.schema.vocabulary.SimpleTerm
> ([...What goes here...?], title=customer.custName)
The value is the customer object itself. The token you are responsible for
creating and depends on you choice above.
> A somewhat derived question:
> - Given a certain Invoice, how do I use the 'reference' to the Customer
> Object to access the Customer of the Invoice?
Python does not know the difference between references and actual objects. :-)
It is smart to handle this itself. So the reference is the object.
CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student)
Web2k - Web Software Design, Development and Training
Zope3-users mailing list