[Zope] HotFixing methods of modules (not classes)

ender kthangavelu@earthlink.net
Sun, 15 Jul 2001 21:47:30 -0700


On Monday 16 July 2001 02:58 am, Peter Bengtsson wrote:
>>I read and used this http://www.zope.org/Members/Caseman/Dynamic_Hotfix
>>
<snip>
>>
>>But it is this that I can't get to work. Here I need help:
>>
>>---- buggyhotfix: __init__.py --------------
>># import function
>>from module import manage_addSomething
>>
>>def myown(self,id):
>>     id = string.upper(id)
>>     self._setObject(id,Something(id))
>>
>>module.manage_addSomething = myown
>>--------------------------------------
>>
>>
>>
>>it's the "module.manage_addSomething = myown" part that looks like the evil
>>thing.
>>
>>Any hints?

you don't have a reference to the module since you're grabbing an explicit 
reference to the class or function in your cases with the from module import 
stuff syntax. instead you could use

import module
module.manage_addSomething = myown
module.ThatClass.ThatFunction = MyNewClassFunction

hth

kapil