On Wednesday 20 February 2008, Hermann Himmelbauer wrote:
> 1.3) From an object attribute (don't really understand what this Step is
> for): Seems also not possible as there's once again no way to register a
> named adapter here and therefore the absence of "value1" as object
> attribute will lead to an error:
>
> adapter = zope.component.queryMultiAdapter(
>                 (self.context, self.request, self.form, self.field, self),
>                 interfaces.IValue, name='default')

You almost got it. This is the approach that I envisioned. You basically have 
to provide this adapter to provide a default value. From 
z3c.formdemo.message.browser, line 27:

DefaultDate = widget.ComputedWidgetAttribute(
    lambda adapter: datetime.date.today(),
    field=interfaces.IHelloWorld['when'], view=IAddForm)

Then register the adapter as follows:

  <adapter
      factory=".browser.DefaultDate"
      name="default" />


You can create any function you like to compute the dynamic default value. The 
`adapter` argument has access to the context, request, form, etc.

Regards,
Stephan
-- 
Stephan Richter
Web Software Design, Development and Training
Google me. "Zope Stephan Richter"
_______________________________________________
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users

Reply via email to