athomerson wrote:
I am starting to use Dexterity and I have run into a couple of issues.  I
have created a content schema (in client.py) and defined a sub-object in it
like so:

     emails = schema.List(
             title=_(u"Email Addresses"),
             value_type = schema.Object(title=u'Emails',
                                        schema=IEmailSubObject),
             required=False,
         )
I then created email.py with the following:

@grok.provider(IContextSourceBinder)
def emailTypes(context):

     terms = []

     pprop = getToolByName(context, 'portal_properties')
     for t in pprop.client_properties.email_types:
         terms.append(SimpleVocabulary.createTerm(t, str(t), t))
     return SimpleVocabulary(terms)

class IEmailSubObject(Interface):
     email_type = schema.Choice(
             title=_(u"Email type"),
             source=emailTypes,
             required=True,
         )
     email_address = schema.TextLine(
         title=_(u"Email address"),
         required=True,
         )
This gives me an error "TypeError: iterable argument required".

Please provide the full traceback when you report an error, it makes it easier to see what's going on. For example, you haven't told us when you get this error. On startup? On the add form? On an edit form? On the view?

Debuging shows that we pass through  zope.schema._field

That file is big. You need to explain which line, and show the surrounding code, if you want to reference it.

three times and the
third time the self.vocabulary is no longer a vocabulary! This seems similar
to the bug (340416) Martin reported on zope3.

Please link to the bug if you want to reference it.

If I change "email_type = schema.Choice(" to "email_type = schema.TextLine("
(and remove "source=emailTypes,") I get a generic error which seems to be
caused by the fact that IEmailSubObject is returning a list rather than an
object.

I don't understand the last sentence.

Am I missing something or am I trying to do something with Dexterity that it
is not ready for?

I don't know yet - you need to be a bit more specific before we can find out what's going.

In general, I'd say that using a List with an Object field as a value type is not a very common thing to do, mainly because the UI for that is pretty rough in z3c.form, and the implications for how the form works are that you probably need to store things in the session. Most people model a one-to-many like this like a container type (the one) with children (the many).

Martin

--
Author of `Professional Plone Development`, a book for developers who
want to work with Plone. See http://martinaspeli.net/plone-book


_______________________________________________
Product-Developers mailing list
[email protected]
http://lists.plone.org/mailman/listinfo/product-developers

Reply via email to