Re: [Zope-dev] zpatterns: how to specify default values?
"Phillip J. Eby" a écrit :
Yes. Name the attributes "class_default_for_X" where X is the attribute name. Thanks very much.
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. I don't use ZClass as I wrote only in Python. I really have to understand how do propery sheets work.
What I don't understand is where the properties are stored. This is not clear when I read the PropertyManager source. I guess property sheets are for grouping some related attributes, but the actual work of storing/retrieving the attribute is done by the attribute providers, right? If so, so be it :-) By the way, - is the python programmer have to mix PropertyManager in with DataSkin to use property sheets? I guess so, but what, I seem to be the only one who use zpatterns directly from python. All the ZClass junkies out there do have all the mixin classes ready even before they start :-) - I sometimes have a dataskin that is willing to get something from its context. What is the preferred way to do this: try to acquire the attribute from self._v_rack, wich is guaranteed to be wrapped in the specialist's context, or just mix Acquisition.Implicit in with DataSkin? regards, jephte.clain@univ-reunion.fr
At 10:37 PM 7/13/00 +0400, Jephte CLAIN wrote:
What I don't understand is where the properties are stored. This is not clear when I read the PropertyManager source. I guess property sheets are for grouping some related attributes, but the actual work of storing/retrieving the attribute is done by the attribute providers, right?
PropertyManager stores properties as attributes. ZClass property sheets generally do the same. So the work gets done by attribute providers if you're using DataSkins.
- is the python programmer have to mix PropertyManager in with DataSkin to use property sheets? I guess so, but what, I seem to be the only one who use zpatterns directly from python. All the ZClass junkies out there do have all the mixin classes ready even before they start :-)
If you're doing it from Python and you just want one property sheet, then the answer is yes. If you want multiple propertysheets, you need propertysheet objects and/or a sheet provider.
- I sometimes have a dataskin that is willing to get something from its context. What is the preferred way to do this: try to acquire the attribute from self._v_rack, wich is guaranteed to be wrapped in the specialist's context, or just mix Acquisition.Implicit in with DataSkin?
DataSkins *are* Acquisition.Implicit already; there should be nothing you need to do. (Yes, I know they don't inherit from it, but that is because they have an alternative implmentation of the __of__ method which is functionally equivalent to that in Implicit, with some extra handling needed by DataSkins.)
participants (2)
-
Jephte CLAIN -
Phillip J. Eby