How to access the attributes of a base class?
Hello, I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Alternatively, I could create a property with the same name like that one from the base class, but this isn't allowed! BTW, it would be nice if this was possible in order to hide the original value - iirc this is usual in object oriented contexts. Does anybody have a suggestion how to do it via DTML? TIA. -- Lars Heber, mailto:Lars.Heber@t-systems.com T-Systems, debis Systemhaus GEI GmbH, Geschaeftsstelle Sachsen
Lars Heber wrote:
Hello, I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Alternatively, I could create a property with the same name like that one from the base class, but this isn't allowed! BTW, it would be nice if this was possible in order to hide the original value - iirc this is usual in object oriented contexts.
Does anybody have a suggestion how to do it via DTML?
aq_parent ?
hans wrote:
Lars Heber wrote:
Hello, I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Alternatively, I could create a property with the same name like that one from the base class, but this isn't allowed! BTW, it would be nice if this was possible in order to hide the original value - iirc this is usual in object oriented contexts.
Does anybody have a suggestion how to do it via DTML?
aq_parent ?
I still tried: <dtml-var "specialFolderInstance.aq_parent.propertysheets.myPropertysheet.myPropertyInTheBaseClass"> and many other possibilities, without success. Anyway, thanks! Anybody other solutions? Thanks. -- Lars Heber, mailto:Lars.Heber@t-systems.com T-Systems, debis Systemhaus GEI GmbH, Geschaeftsstelle Sachsen
At 05.04.2002 18:06 +0200, Lars Heber wrote:
hans wrote:
Lars Heber wrote:
Hello, I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Alternatively, I could create a property with the same name like that one from the base class, but this isn't allowed! BTW, it would be nice if this was possible in order to hide the original value - iirc this is usual in object oriented contexts.
Does anybody have a suggestion how to do it via DTML?
With ZClasses you will have to give different names to the propertysheets in order to be able to access a base class' properties. You can then do something along the lines of (untested): <dtml-var "propertysheets.baseClassSheet.aProperty"> <dtml-var "propertysheets.thisClassSheet.aProperty"> HTH, Stefan -- BLOWFISH n. - Preference for beef
Lars Heber writes:
I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Not sure, I understand your problem...
It is trivial to access a property defined in a base class (provided it is not overwritten in the derived class): instance.property_defined_in_base_class But, I must miss something as it is too simple... Dieter
Dieter Maurer wrote:
Lars Heber writes:
I have a ZClass Folder and a ZClass SpecialFolder, which has Folder as base class. Within an instance of SpecialFolder, I need access to a property declared in the base class Folder. Not sure, I understand your problem...
It is trivial to access a property defined in a base class (provided it is not overwritten in the derived class):
instance.property_defined_in_base_class
But, I must miss something as it is too simple...
Dieter
Sorry, I forgot to mention that I want to CHANGE that property in the base class, i. e. apply manage_change to the property. I try to explain my problem again: Actually, I want users to change a property prop_in_base_class. I noticed that in the subclass SpecialFolder, I cannot create a view that shows the corresponding property sheet of the base class. So, as an alternative, I wanted to change this property via dtml. I still tried: <dtml-call "mySpecialFolderInstance.propertysheets.attributes.manage_changeProperties({'property_in_base_class':'new_value'})"> When I do this with properties of the sub class, everything works fine. But the above doesn't work. No error, just the unchanged value remains. Both the base class and the sub class have a property sheet with the same name. I just tried to create a new property sheet in the base class and create for it a view in the base class. But wait - hooray, I've got it!!! Now, I created in the sub class a dummy method which just redirects to this property sheet - and it works!!! The only content of this dummy method is: <dtml-call "RESPONSE.redirect('propertysheets/newPropertySheetInBaseClass/manage')"> Created a view for this method in the sub class, and here we are! So, thanks to you all! I'll stay with this method if nobody can tell me a simpler way to do it. -- Lars Heber, mailto:Lars.Heber@t-systems.com T-Systems, debis Systemhaus GEI GmbH, Geschaeftsstelle Sachsen
For the interested: An addition to my solution: In a sub class, you can create a view to a property sheet of the base class directly without that dummy method and redirect thing, provided that you create a view for that property sheet in the BASE class as well. You then have in the sub class in the views tab the option to directly select propertysheets/prop_sheet_in_base_class/manage as a new View. Thanks. -- Lars Heber, mailto:Lars.Heber@t-systems.com T-Systems, debis Systemhaus GEI GmbH, Geschaeftsstelle Sachsen
participants (4)
-
Dieter Maurer -
hans -
Lars Heber -
Stefan H. Holek