[Zope-dev] A Modest Proposal Concerning Monkey Patches

Casey Duncan casey@zope.com
Tue, 13 Aug 2002 13:56:22 -0400


I know I will regret that I said this, but this is really symptomatic of =
a=20
more basic need. The need to extend manage_main.

This has been identified as a hot spot for products to "monkey" with. Why=
=20
don't we go right to the source and make manage_main extensible so that=20
monkey patching it isn't necessary?

-Casey

On Tuesday 13 August 2002 01:22 pm, Jim Penny wrote:
> There is a large problem looming with Moneky Patches.  The problem is
> that monkey patches are so Highlander.  "There can be Only One".
>=20
> For example, there are at least five or six products that monkey patch
> manage_main.   Each simply replaces whatever manage_main exists at the
> time of instantation, and blows away any previous monkey patch.  Some
> coordinated way of dealing with this problem needs to be arrived at.
>=20
> Proposal:
>=20
>   for concreteness sake, suppose manage_main is being patched.
>=20
>   A monkey patch author does the following:
>=20
>   1)  checks to see if the file being patched is in $(INSTANCE_HOME)/tm=
p
>    =20
>     A)  If not, he proceeds directly with the patch
>=20
>     B)  If so, he makes whatever checks he can to determine if he can
>         update the file in $(INSTANCE_HOME)/tmp.
>=20
> =09i)  If he cannot, it is his decision whether to follow current
> =09    practice and simply blow away the current monkey patch=20
> =09    (Boo!  Hiss!)  or,
> =09
> =09ii)  fail (sigh, curse!).
>=20
>   2)  If the monkey patch is installed, then the installed file is
>      written in $(INSTANCE_HOME)/tmp.  I.e., the new manage_main.py
>      is written to $(INSTANCE_HOME)/tmp.
>=20
>   This assumes that z2.py is modified so that it clears out
>   $(INSTANCE_HOME)/tmp on each start.
>=20
> It might be also be a good idea to keep a section of comments at the
> top of the monkeypatch file showing the history of monkeypatch
> application.
>=20
> Comments?
>=20
> Jim Penny
>=20
> _______________________________________________
> Zope-Dev maillist  -  Zope-Dev@zope.org
> http://lists.zope.org/mailman/listinfo/zope-dev
> **  No cross posts or HTML encoding!  **
> (Related lists -=20
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope )
>=20