doc/book/en/devrepo/entityclasses/adapters.rst
changeset 8190 2a3c1b787688
parent 8032 bcb87336c7d2
child 9256 697a8181ba30
equal deleted inserted replaced
8189:2ee0ef069fa7 8190:2a3c1b787688
    43 
    43 
    44 .. Note::
    44 .. Note::
    45 
    45 
    46    Adapters came with the notion of service identified by the registry identifier
    46    Adapters came with the notion of service identified by the registry identifier
    47    of an adapters, hence dropping the need for explicit interface and the
    47    of an adapters, hence dropping the need for explicit interface and the
    48    :class:`cubicweb.selectors.implements` selector. You should instead use
    48    :class:`cubicweb.predicates.implements` selector. You should instead use
    49    :class:`cubicweb.selectors.is_instance` when you want to select on an entity
    49    :class:`cubicweb.predicates.is_instance` when you want to select on an entity
    50    type, or :class:`cubicweb.selectors.adaptable` when you want to select on a
    50    type, or :class:`cubicweb.predicates.adaptable` when you want to select on a
    51    service.
    51    service.
    52 
    52 
    53 
    53 
    54 Specializing and binding an adapter
    54 Specializing and binding an adapter
    55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    55 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    77 
    77 
    78 Here we go with a small example. Before:
    78 Here we go with a small example. Before:
    79 
    79 
    80 .. sourcecode:: python
    80 .. sourcecode:: python
    81 
    81 
    82     from cubicweb.selectors import implements
    82     from cubicweb.predicates import implements
    83     from cubicweb.interfaces import ITree
    83     from cubicweb.interfaces import ITree
    84     from cubicweb.mixins import ITreeMixIn
    84     from cubicweb.mixins import ITreeMixIn
    85 
    85 
    86     class MyEntity(ITreeMixIn, AnyEntity):
    86     class MyEntity(ITreeMixIn, AnyEntity):
    87         __implements__ = AnyEntity.__implements__ + (ITree,)
    87         __implements__ = AnyEntity.__implements__ + (ITree,)
    95 
    95 
    96 After:
    96 After:
    97 
    97 
    98 .. sourcecode:: python
    98 .. sourcecode:: python
    99 
    99 
   100     from cubicweb.selectors import adaptable, is_instance
   100     from cubicweb.predicates import adaptable, is_instance
   101     from cubicweb.entities.adapters import ITreeAdapter
   101     from cubicweb.entities.adapters import ITreeAdapter
   102 
   102 
   103     class MyEntityITreeAdapter(ITreeAdapter):
   103     class MyEntityITreeAdapter(ITreeAdapter):
   104         __select__ = is_instance('MyEntity')
   104         __select__ = is_instance('MyEntity')
   105 
   105