[Zope3-Users] Re: Newbie relationship question
ccardelli at iv-srl.it
Thu Jul 27 05:17:19 EDT 2006
[Sorry to start a new thread, but I had 'Reply-To' disabled...]
Albertas Agejevas wrote:
> > Now, I have to render the 'invCust' object as a selection-list showing
> > the custNames of all possible Customers, where the user can select the
> > appropriate Customer for the Invoice. Editing the Invoice, the
> > selection-list should position itself showing the Customer set
> > In other words, I need a widget that somewhat behave like
> > "Plone.Archetypes.ReferenceWidget".
> > I know that this is a very basic problem. Anyone already implemented it?
> What you need to do is define the customer field as a choice in the
> class IInvoice(Interface):
> invCust = Choice(title=u"Customer",
> and define the "Customers" vocabulary, that will list all customers in
> your app. Look at zope.schema.vocabulary.SimpleVocabulary.
Thank for your answer, that gave me a starting point.
Sorry to be annoying, but after such starting point I am stuck again:
- how do I get all my Customers instances? The Customer class is marked
as 'Persistent' and 'IContentType'.
- how do I connect them to the vocabulary in a way to store a
'reference' to the object and not, say, only its custName?
I have to fill 2 slots in the following:
allterms = 
for customer in [ ...What goes here...? ]:
oneTerm = zope.schema.vocabulary.SimpleTerm
([...What goes here...?], title=customer.custName)
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?
Again, these are basic questions, but I am not able to find
documentation about this.
More information about the Zope3-users