Re: [Zope] Extending Zope system code without editing
At 06:56 AM 3/4/2003, Dennis Allison wrote:
From time to time I want to do things to the Zope system code, for example, add a new method or override a method in a pre-existing class. Is there a good way to do this within the Zope system structure. I'd like to keep my changes isolated and use the inheritance and namespace mechanisms of Python rather than hard edits.
Inheritance is probably your answer here. You can either subclass an existing object or mix your code into an existing object's definition. Say you want to add a method to a Folder. One way is to make a basic product called my_folder, mix in Folder as a base class and then start overriding and extending. Then, in the ZMI you'll have the option of whether to use a standard Zope folder or one of your custom Folders. On the other hand, you could create a Python module called my_folder_changes, create a simple class called my_folder and use it to define the behaviors you want to see. Then add your class to the *front* of the list of base classes inherited by Folder. This won't override anything actually defined in Folder's class definition... you'll need to comment those out to override them with this technique. Is that what you're looking for? HTH, Dylan
Not quite... How do I modify a class defined in lib/python/StructuredText or lib/python/ZPublisher or the like with the minimum of fuss and without patching the actual distributed Zope system code... On Tue, 4 Mar 2003, Dylan Reinhardt wrote:
At 06:56 AM 3/4/2003, Dennis Allison wrote:
From time to time I want to do things to the Zope system code, for example, add a new method or override a method in a pre-existing class. Is there a good way to do this within the Zope system structure. I'd like to keep my changes isolated and use the inheritance and namespace mechanisms of Python rather than hard edits.
Inheritance is probably your answer here.
You can either subclass an existing object or mix your code into an existing object's definition.
Say you want to add a method to a Folder.
One way is to make a basic product called my_folder, mix in Folder as a base class and then start overriding and extending. Then, in the ZMI you'll have the option of whether to use a standard Zope folder or one of your custom Folders.
On the other hand, you could create a Python module called my_folder_changes, create a simple class called my_folder and use it to define the behaviors you want to see. Then add your class to the *front* of the list of base classes inherited by Folder. This won't override anything actually defined in Folder's class definition... you'll need to comment those out to override them with this technique.
Is that what you're looking for?
HTH,
Dylan
On Tue, Mar 04, 2003 at 08:50:39AM -0800, Dennis Allison wrote:
Not quite... How do I modify a class defined in lib/python/StructuredText or lib/python/ZPublisher or the like with the minimum of fuss and without patching the actual distributed Zope system code...
i already told you :) -- Paul Winkler http://www.slinkp.com
participants (3)
-
Dennis Allison -
Dylan Reinhardt -
Paul Winkler