[Grok-dev] How do I use schema.Object?

Martin Aspeli optilude+lists at gmail.com
Tue Mar 10 10:40:16 EDT 2009


Sebastian Ware wrote:
> I am having difficulties understanding how to render forms using  
> schema.Object. I have looked at various Zope 3 samples, but I am  
> failing to translate it to Grok. The doctests I have found aren't  
> helping me either.
> 
> Does anybody have some code that would successfully render and update  
> an object field?
> 
> class IEvent(Interface):
>      show_in_calendar = schema.Bool(title=u"Show in calendar")
>      event_date = schema.Date(title=u'Date', required = False)
> 
> class INews(IStory):
>      event = schema.Object(title=u"Event", schema = IEvent)

What is the problem, exactly? An object field just says "this attribute 
stores an object that complies with this interface (schema)". It'll need 
a widget just like any other field to be rendered. I'm not sure if 
formlib has a default widget for Object, though it probably could by 
rendering some kind of sub-form.

Martin

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



More information about the Grok-dev mailing list