[Zope-Coders] Re: [Zope-Checkins] CVS: Zope27/lib/python/TAL - TALInterpreter.py:1.68.26.2

Florent Guillaume fg@nuxeo.com
09 Sep 2002 16:32:22 +0200


[on zope-coders]

On Mon, 2002-09-09 at 16:21, Casey Duncan wrote:
> I guess I am curious why this would be necessary, couldn't you already just 
> do:
> 
> import TAL.TALInterpreter
> import MyStringIO
> TAL.TALInterpreter.StringIO = MyStringIO.StringIO

I wished it worked, but it doesn't, the rest of the TALIntepreter code
still holds a reference to the original StringIO.

> Its still a messy monkey patch but at least you wouldn't need to change the 
> framework.
> 
> It seems ridiculous to change the framework so that you can monkey patch it. 
> The whole point of monkey patches is to change the framework at run time 
> without changing the framework code itself.

"Changing the framework" is maybe overstating what this is: just a
temporary hack.

> If the above is inadequate, then I think some other mechanism should be 
> devised. Such as a module function like Guido suggested. Defining things as 
> monkey patch hooks is setting a bad precedent IMO.

A module function probably would be a little bit cleaner, yes. I can do
that. But it'd still be a monkey-patch hook :-)

Florent
 
-- 
Florent Guillaume, Nuxeo (Paris, France)
+33 1 40 33 79 87  http://nuxeo.com  mailto:fg@nuxeo.com