[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
previously.
> 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
interface:
class IInvoice(Interface):
...
invCust = Choice(title=u"Customer",
vocabulary="Customers")
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:
def CustomerVocabulary():
allterms = []
for customer in [ ...What goes here...? ]:
oneTerm = zope.schema.vocabulary.SimpleTerm
([...What goes here...?], title=customer.custName)
allterms.append(oneTerm)
return zope.schema.vocabulary.SimpleVocabulary(allterms)
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.
_______________________________________________
Zope3-users mailing list
[email protected]
http://mail.zope.org/mailman/listinfo/zope3-users