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

Sebastian Ware sebastian at urbantalk.se
Tue Mar 10 11:15:40 EDT 2009


I need somehow to specify what widget to use. I got the impression  
that these might help:

   from zope.app.form import CustomWidgetFactory
   from zope.app.form.browser import ObjectWidget

I read a discussion here:

   http://mail.zope.org/pipermail/zope3-users/2005-August/000923.html

Got the impression that I could create such a widget automagically,  
but I just got a bunch of different errors. Maybe someone has done  
this in Grok and I might be in the wrong corner to start with when I  
am looking at Zope 3 solutions from 2005...

Mvh Sebastian

10 mar 2009 kl. 15.40 skrev Martin Aspeli:

> 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
>
> _______________________________________________
> Grok-dev mailing list
> Grok-dev at zope.org
> http://mail.zope.org/mailman/listinfo/grok-dev



More information about the Grok-dev mailing list