[Zope-dev] multiple monkeypatches
Adrian Hungate
adrian@haqa.co.uk
Wed, 5 Jun 2002 22:51:45 +0100
PatchKit handles this for you (If you ask it to).
:)
Adrian...
--
Adrian Hungate
EMail: adrian@haqa.co.uk
Web: http://www.haqa.co.uk
Computers are like air conditioners
-- they stop working properly if you open WINDOWS
----- Original Message -----
From: "Florent Guillaume" <fg@nuxeo.com>
Newsgroups: local.lists.zope.zope-dev
To: <zope-dev@zope.org>
Sent: Wednesday, June 05, 2002 6:15 PM
Subject: Re: [Zope-dev] multiple monkeypatches
> Jim Penny <jpenny@universal-fasteners.com> wrote:
> > Is there a safe way to handle multiple monkeypatches?
>
> Without an existing framework (I haven't looked at Adrian's PatchKit),
> it's the same old problem as "intercepting interrupts" on good old 8-bit
> computers. You just have to save and call the previous one.
>
> What I do is this:
>
> # 1. define my method
> def manage_main(...):
> # ...
> ...
> res = self._myproduct_old_manage_main(...)
> ...
> return res
> # 2. put the old version in a private variable
> ObjectManager._myproduct_old_manage_main = ObjectManager.manage_main
> # 3. patch
> ObjectManager.manage_main = manage_main
>
> If you want to play nice with refresh, you have to be a bit more
> careful, because then you don't want to do step 2. A simple test for
> absence of the _myproduct_old_manage_main attribute before doing it is
> enough.
>
> Florent
>
> --
> Florent Guillaume, Nuxeo (Paris, France)
> +33 1 40 33 79 87 http://nuxeo.com mailto:fg@nuxeo.com
>
>
> _______________________________________________
> Zope-Dev maillist - Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://lists.zope.org/mailman/listinfo/zope-announce
> http://lists.zope.org/mailman/listinfo/zope )
>