[PEAK] gf.when() doesn't honour Interfaces on instances (protocols.adviseObject)

Radek Kanovsky rk at dat.cz
Thu Dec 2 09:57:26 EST 2004


On Thu, Dec 02, 2004 at 03:35:46PM +0100, Ulrich Eck wrote:

>     [callMethod.when("self is IPPStatePrivate and > event.name=='submit'")]
>     def callMethod_submit(self, event):
>         print "Submit", event
>         protocols.adviseObject(self,provides=[IPPStatePending],
>                                 doesNotProvide=[IPPStatePrivate])
> 
>     [callMethod.when("self is IPPStatePending and > event.name=='publish'")]
>     def callMethod_publish(self, event):
>         print "Publish", event
>         protocols.adviseObject(self,provides=[IPPStatePublished],
>                                doesNotProvide=[IPPStatePending])
> 
>     [callMethod.when("self is IPPStatePublished and > event.name=='retract'")]
>     def callMethod_retract(self, event):
>         print "Retract", event
>         protocols.adviseObject(self,provides=[IPPStatePrivate],
>                                doesNotProvide=[IPPStatePublished])

Hi,

I think, that you should replace ``is'' by ``in'' in all predicates.

    "self in IPPStatePublished and > event.name=='retract'"

> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "<string>", line 5, in callMethod
>   File "/usr/lib/python2.3/site-packages/dispatch/functions.py", line
> 319, in __getitem__
>     raise NoApplicableMethods
> dispatch.interfaces.NoApplicableMethods

I have a small suggestion. It would be sometimes very helpful if one can see
also arguments supplied to generic method in traceback output:

    raise NoApplicableMethods(args)

instead of

    raise NoApplicableMethods

RadekK



More information about the PEAK mailing list