[PEAK] protocols question

Gabriel Jägenstedt gabriel.j at telia.com
Sun Mar 28 14:37:44 EST 2004

There is a thing that has been bothering me with pyprotocols.
I have been trying to use adapt to get an instance of a component as I
belive is the meaning of it.

I asume there is something missing from my code but I haven't been able
to find any reference to how it all should be set up.

Anyway as it's only a test the code is quite meaningless.

class IEdible(Interface):
    """Implements an edible behaviour on objects"""

    def __init__():
        """a number of attributes that should be enabled in child"""

    def PreObj(self, cmd=''):
        """returns a cmd'string'"""

class Food:
    advise(instancesProvide = [IEdible])

    def __init__(self, pNames=''):
        self.id = 12

    def PreObj(self, cmd=''):
        print 'hurray'

adapt(IEdible, Food)

when I run adapt I get the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "inter.py", line 27, in ?
    adapt(IEdible, Food)
  File "C:\cygwin\home\pje\PyProtocols\src/protocols/_speedups.pyx",
line 183, in _speedups.adapt  File
"C:\cygwin\home\pje\PyProtocols\src/protocols/_speedups.pyx", line 87,
in _speedups.IMPLEMENTATION_ERROR NotImplementedError: ("Can't adapt",
<class 'inter.IEdible'>, <class inter.Food at 0x401eae3c>)

I was guessing this is because I am missing something somewhere, however
I'm not sure what, I can't find any examples that do something this
simple. Only based on types.

If any help can be provided I'd be much obliged.


More information about the PEAK mailing list