[Zope3-Users] Adapting or monkey patching?

Drew Smathers drew.smathers at gmail.com
Thu Sep 13 09:25:38 EDT 2007


> Currently I have a adapter that subclasses OFS.SimpleItem.Item and
> re-implements the raise_standardErrorMessage method with my line of
> code that sends the event.

I have know idea what OFS is, but what you're describing isn't an
adapter at all.  I would try writing a real adapter like:

class OFSToCallable(object):
   implements(ICallalable) # ICallable is a stub interface
   adapts(OFS.interfaces.IItem)

   def __init__(self, ctx):
       self.ctx = ctx

   def __call__(self, *p, **kw):
       try:
           self.ctx(*p, **kw)
       except Exception, e:
            # handle the exception and dispatch event here
            pass


I'm just a zope dilettante, so take my advice with a grain of salt.

-- 
\\\\\/\"/\\\\\\\\\\\
\\\\/ // //\/\\\\\\\
\\\/  \\// /\ \/\\\\
\\/ /\/ / /\/ /\ \\\
\/ / /\/ /\  /\\\ \\
/ /\\\  /\\\ \\\\\/\
\/\\\\\/\\\\\/\\\\\\
               d.p.s


More information about the Zope3-users mailing list