[Zope] HotFixing methods of modules (not classes)
Evan Simpson
evan@4-am.com
Mon, 16 Jul 2001 14:21:14 -0400
Peter Bengtsson wrote:
> 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
> --------------------------------------
As Casey mentioned, this will fail as written because 'module' isn't
defined. You need to 'import module'. There's a problem implicit in
the name you're overriding, though. If 'manage_addSomething' is a
constructor, as its name suggests, it has probably been registered with
the Zope machinery by the time you get around to replacing it in the
module namespace. Check to see whether 'manage_addSomething' is passed
to a registration function in 'module'.
Cheers,
Evan @ digicool & 4-am