[Zope-dev] zpatterns: how to specify default values?
Phillip J. Eby
pje@telecommunity.com
Thu, 13 Jul 2000 08:47:22 -0500
At 12:24 PM 7/13/00 +0400, Jephte CLAIN wrote:
>hello,
>
>a common practice is to put default values for attributes for a classe
>as class variables.
>if the instance hasn't got the value, it gets the value from the class.
>
>but I can't do this with dataskins, because direct dataskins attributes
>take precedence on attributes providers.
>
>the way I do it now is to make a default_attributes attribute provider
>which provides defaults. is this correct?
>or is there a better way to do this?
Yes. Name the attributes "class_default_for_X" where X is the attribute
name. This works with the currently release ZPatterns, but alpha5 will go
one better and let you create ZClass property sheets that transparently
implement this. That is, if you add a "DataSkin Property Sheet" to your
ZClass instead of the standard "Common Instance Property Sheet", that
sheet's attributes will be translated to/from the "class_default_for_X"
names on the ZClass.