[Grok-dev] How do I get current day as default in interface schema definition?

Steve Schmechel steveschmechel at yahoo.com
Tue Feb 17 12:07:24 EST 2009


It does help.  I guess I was reading the how-to thinking (wrongly) that the ".field." portion was replaceable with one's own code like the 'name' portion is.

    form_fields['name'].field.title = u'Fill in your name'
    form_fields['name'].field.default = u'My name'

Maybe the documentation should be updated to show what is recommended when desiring defaults for schema based fields, as it currently speaks more to using "widgets".  (A comment on the page already points out some possible confusion.)

Also, what *should* the "default" property of zope.schema be used for?

There is an example in the "grok.adapts" section of the "The Grok Reference" for "Directives"(which I DO keep under my pillow ;-) that shows the "default" property being used with schema.TextLine. 

http://grok.zope.org/doc/current/reference/directives.html#grok-adapts-declare-that-a-class-adapts-certain-objects

When I try this technique and create a new object based on the interface that specifies the schema, it does not work (the point of this thread). 

Should that example be removed from the reference?  Does the property even work in the larger Zope3 sense?  If not, maybe it should come out of zope.schema.

Thanks,
Steve


--- On Tue, 2/17/09, Jan-Wijbrand Kolman <janwijbrand at gmail.com> wrote:

> From: Jan-Wijbrand Kolman <janwijbrand at gmail.com>
> Subject: Re: [Grok-dev] How do I get current day as default in interface  schema definition?
> To: steveschmechel at yahoo.com
> Cc: "Sebastian Ware" <sebastian at urbantalk.se>, "Grok list" <grok-dev at zope.org>
> Date: Tuesday, February 17, 2009, 7:50 AM
> On Tue, Feb 17, 2009 at 2:41 PM, Steve Schmechel
> <steveschmechel at yahoo.com> wrote:
> >
> > I ran into this same problem and was confused by other
> examples I found in other sample code that are written like
> you suggest.
> >
> > Don't these contradict the warning in the
> "Customising Fields in Grok" how-to, which
> explicitly states no to do something like this in your add
> form?  (It mostly warns about changing the field name, but
> setting the default is included in the example.)
> >
> > See the "Further Information" section in:
> >
> >
> http://grok.zope.org/documentation/how-to/customizing-form-fields-in-grok-forms
> 
> The example warns for modifying the (schema)field attribute
> on the
> form(field) object. This is confusing. But, the FormField
> objects that
> come from grok.AutoFields are wrappers around zope.schema
> Field
> objects. If you would modify the latter, it indeed
> propagate
> throughout the runtime.
> 
> The FormFields however are pre-request and do have hooks
> for local
> modifications.
> 
> Does this make it anymore clear?
> 
> regards,
> jw


      


More information about the Grok-dev mailing list