[Zope] Extending Zope system code without editing
Dylan Reinhardt
zope@dylanreinhardt.com
Tue, 04 Mar 2003 08:37:08 -0800
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