[Zope3-Users] Recipe with default values

Marco Mariani marco at sferacarta.com
Thu Feb 16 17:48:03 EST 2006


In chapter 5.4 of the cooking book, Philipp says:

> [...] We could now implement a custom factory, for example one that 
> allows us to set initial attribute values of the recipe. (We would 
> normally extend the Recipe class with a constructor to do that, but 
> let us implement a factory here for demonstration purposes.)

How should I write the constructor? I've tried the naive __init__ method 
but I must be missing something, as it doesn't get passed any argument.

For instance, I'd like to have an attribute recipe.creation_date which 
is editable in the addform but has datetime.datetime.now() as a default 
value.

Of course if I simply add creation_date=datetime.datetime.now() in the 
class definition, it gets the time once at the start.


thanks for the help, the shiny release, the book and the appetizers. i'm 
getting hungry :-)



More information about the Zope3-users mailing list