On Friday 12 October 2007, Raphael Ritz wrote: > 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.
z3c.form supports default value adapters, which allow you to compute a default value before the form is first displayed. Regards, Stephan -- Stephan Richter CBU Physics & Chemistry (B.S.) / Tufts Physics (Ph.D. student) Web2k - Web Software Design, Development and Training _______________________________________________ Zope3-users mailing list Zope3-users@zope.org http://mail.zope.org/mailman/listinfo/zope3-users