Re: [Zope3-Users] Adapting or monkey patching?

2007-09-13 Thread Drew Smathers
 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
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users


[Zope3-Users] Adapting or monkey patching?

2007-09-12 Thread Fernando Correa Neto
Hello everyone.

Since there's no default adapter for OFS.interfaces.IItem, I was
wondering the best approach to patch/adapt OFS.SimpleItem.Item
raise_standardErrorMessage method so it sends an event upon errors.
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 also have an event subscriber for that event BUT it does not work of
course, because there's no adapter been called.

Any clues or experiences to share?

Regards,
Fernando
___
Zope3-users mailing list
Zope3-users@zope.org
http://mail.zope.org/mailman/listinfo/zope3-users