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

Raphael Ritz r.ritz at biologie.hu-berlin.de
Fri Oct 12 09:59:51 EDT 2007


Piotr Chamera wrote:
> Hi,
> I am new in zope (3.3) and schema and cant find how to calculate default
> value for readonly schema field. I want to set current date as default
> date for field (and show this in schema) - in schema I can set
> "default = datetime.now()" but it evaluates once at zope startup, I need 
> it evaluated at attribute access time. How to do it?
> 

I have no clue but what happens if you use "default = datetime.now"
aka without calling it. The rationale being if it's a callable
(or maybe a string representation of a callable) it gets invoked when
needed.

In Archetypes at least we have this pattern at places while for the 
default we destinguish explicitly between a 'default' (value) and a
'default_method' (to be evaluated at run time).

Last time this came up here (which is quite a while ago) this was
not supported. Don't know if that changed.

Raphael


> Piotr Chamera



More information about the Zope3-users mailing list