[Zope-CMF] CMFDefault.utils is not monkey-patchable

Chris Withers chrisw@nipltd.com
Wed, 13 Nov 2002 13:44:32 +0000


Paul Winkler wrote:
> <rant>
> I like doing "monkey patches" to change default behavior
> of downloaded Zope products without having to build
> wrapper products or patch the actual source.

Ah, many other people see them as 'bad' ;-)

>>>>from Products.CMFDefault.utils import scrubHTML
>>>>scrubHTML.__name__
>>>
> 'scrubHTML'
> 
> Here's the weird bit:
> 
> 
>>>>import Products.CMFDefault.utils
>>>>hasattr(Products.CMFDefault.utils, 'scrubHTML')
>>>
> 0

Why does that matter?

> This is bad, because CMFCore/utils.py now "masks"
> CMFDefault/utils.py such that you can ONLY get
> at attributes of the latter by importing them
> directly into the current namespace, as in:
> from Products.CMFDefault.utils import foo

Don't follow you. How is that different from:

from Products.CMFDefault import utils
foo = utils.foo

?

> IMHO this is Bad and Wrong. "from foo import bar"
> is generally frowned upon due to namespace pollution

No its not. It's generally the recommended way of bringing in oftne used names 
from other modules and packages.

I still fail to see what your problem actually.

Does:

Products.CMFDefault.utils.scrubHTML = xxx

not work?

cheers,

Chris