[Zope] HotFixing methods of modules (not classes)

Peter Bengtsson mail@peterbe.com
Mon, 16 Jul 2001 11:58:41 +0200


I read and used this http://www.zope.org/Members/Caseman/Dynamic_Hotfix

This works great for changing methods and stuff inside classes, but what
about stuff that isn't inside the class?
(Maybe more of a Python question rather than Zope)

--- module.py  ----------

def manage_addSomething(self,id):
     self._setObject(id,Something(id))

class Something(SimpleItem):
      def __init__(self,id):
           self.id = id
      del somemethod(self):
           return "hello"
----------------------------

This I can HotFix like this:

---- hotfix: __init__.py --------------
# import class
from module import Something

def myown(self):return "Hello!"

Something.somemethod = myown
--------------------------------------


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?

Cheers,
Peter