[Zope3-Users] Re: Computed default in zope schema

Raphael Ritz r.ritz at biologie.hu-berlin.de
Fri Oct 12 12:01:45 EDT 2007


Fred Drake wrote:
> On 10/12/07, Raphael Ritz <r.ritz at biologie.hu-berlin.de> wrote:
>> Last time this came up here (which is quite a while ago) this was
>> not supported. Don't know if that changed.
> 
> This isn't currently part of zope.schema. 

But maybe that will change one day?

> Exactly what the right
> thing is isn't clear (at least to me).
> 

it's hard indeed

> Sometimes, when filling in forms, the default value can reasonably be
> computed before the initial display,

so that could be handled by something like a 'default_method'
meaning something that gets evaluated *before* the add form gets
even rendered. Obviously there are limits to what the method
can depend upon.

> and at other times is needs to
> happen when the form is processed at the end.

Or maybe even in-between (like after some other information
has been given) ...

In Archetypes we have the MasterSelectWidget
https://svn.plone.org/svn/archetypes/MoreFieldsAndWidgets/MasterSelectWidget/
for such things.

>  This might be because
> the default value requires other inputs as part of the computation, or
> because it's time-sensitive.
> 

If it's purely dependent on other input then I wouldn't call it a
default anymore but rather an "inferred value" (or whatever you may
want to call it). Again, in Archetypes, we have the so-called
"ComputedField" for such things.

Now why am I quoting Archetypes here several times?
Firstly, because that is something I'm somewhat familiar
with because I've been using it for 5 years now (and contributing
every now and then ...).

But more importantly this is because I want to convey the message
that while we - the Plone community - are eagerly wanting to move
forward and to adopt more and more of what Zope 3 has to offer we
still have a hard time advocating the move away from Archetypes to
zope.schema/form/formlib/...

One reason being that even today there is no library in zope that
would contain a variety of widgets rich enough to offer what
Archetypes provides since years. This simply doesn't make it easier
to move away from Archetypes. (and of course I know that I can
always write my own widgets but that's not the point here)

Raphael (in his Friday afternoon - in Stockholm actually evening -
rant mode; sorry)


> 
>   -Fred
> 



More information about the Zope3-users mailing list