[z3-five] "Could not adapt" problem

Petri Savolainen petri.savolainen at iki.fi
Fri Dec 17 16:05:59 MET 2004


My first stab at trying out five... I am trying to adapt

class OriginalItem:

    implements(IOrganizationItem)
    ....

When I try adapted = IOrganizationRetrieval(OriginalItem()) I get a 
'Could not adapt', <OriginalItem instance at ...>, <InterfaceClass 
IOrganizationRetrieval...>.

All seems as it should yet is not... any hints would be appreciated. The 
interfaces, classes and zcml are here.

interfaces:
---------------

class IOrganizationItem(Interface):
    """Empty placeholder"""

class IOrganizationRetrieval(Interface):
    """Support retrieval of the containing organization"""


classes and adapters:
----------------------------------

class OrganizationItem():
    """Folderish organization"""

    implements(IOrganizationItem)


class OrganizationRetrievalAdapter:
    """Adapts to IOrganizationItem. Note that original needs to contain 
organizationitemschema"""

    implements(IOrganizationRetrieval)

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


configure.zcml:
----------------------

<configure xmlns="http://namespaces.zope.org/zope">
   <adapter
       for=".interfaces.IOrganizationItem"
       provides=".interfaces.IOrganizationRetrieval"
       factory=".classes.OrganizationRetrievalAdapter" />
</configure>



More information about the z3-five mailing list