On Thu, 2002-02-07 at 10:36, Andre Schubert wrote:
P.S.: I hope there is someone understanding this :)
I think I do, although I think it'd be clearer see some code than parse overused foo and bar words from pure english :-)
i have a little question on ZCLasses and Python. Lets Say i have python-base-class foo which is folderish. I have a zclass bar which has the class foo as base class. Now i have defined as new propertysheet instance in bar called foobar.
so, let's say you have an instance of your ZClass, called "barInstance". The propertySheet would be addressed as "barInstance.foobar"
If i change the properties of foobar, then manage_editProperties is called( i'am right ).
Actually, if you want to change a property from "barInstance.foobar" (say, "someProperty", which is a string property) you'd rather call "barInstance.foobar.manage_changeProperties(someProperty='someString')" or "barInstance.foobar.manage_changeProperties(someDictionary)", where "someDictionary = {'someProperty' : 'someString}". "barInstance.foobar.manage_editProperties" is used when you want to pass the request straight from a web form to change all the properties in one sitting, where the browser might not send form fields for, say, an unchecked checkbox, which would mean you want to set a boolean property to None, but you'd never know by just looking at the REQUEST since the variable wouldn't be there. That means you should be careful when using manage_editProperties, because you might change properties you weren't expecting to be changed.
Is there a way to catch the manage_editProperties function(called from foobar) in my base-class foo ????
No, unless you subclass propertySheets to make your own version, but then you wouldn't have an easy way to use it when making your ZClasses thru the ZMI. Keep in mind though, that Folder is a PropertyManager, so you can call "barInstance.manage_changeProperty(someProperty='someString')" without the need to mess with propertySheets. If bar were a Python class instead of a ZClass (or if bar inherited from a Python class that inherited from Folder) you'd be able to override manage_changeProperty to do whatever you wanted it to do before calling Folder.manage_changeProperty(...), but with ZClasses I don't know of any way of calling a superclass method, which I think is a great limiting factor of the utility of ZClasses. As a rule of thumb, I always create a Python base class for my ZClasses and inherit only from it and, from this Python base class, I inherit from any other class I need. This simplifies the task of changing base classes from a ZClass should the need come, and allow me to do stuff in that I wouldn't be able to do from the ZClass alone. Hope any of this helps you. Cheers, Leo -- Ideas don't stay in some minds very long because they don't like solitary confinement.