17 lines
1.1 KiB
Text
17 lines
1.1 KiB
Text
PyProtocols extends the PEP 246 adapt() function with a new "declaration
|
|
API" that lets you easily define your own protocols and adapters, and
|
|
declare what adapters should be used to adapt what types, objects, or
|
|
protocols. In addition to its own Interface type, PyProtocols can also use
|
|
Twisted and Zope's Interface types too. (Of course, since Twisted and Zope
|
|
interfaces aren't as flexible, only a subset of the PyProtocols API works
|
|
with them. Specific limitations are listed in the documentation.)
|
|
|
|
If you're familiar with Interface objects in Zope, Twisted, or PEAK, the
|
|
Interface objects in PyProtocols are very similar. But, they can also do
|
|
many things that no other Python interface types can do. For example,
|
|
PyProtocols supports "subsetting" of interfaces, where you can declare that
|
|
one interface is a subset of another existing interface. This is like
|
|
declaring that somebody else's existing interface is actually a subclass of
|
|
the new interface. Twisted and Zope don't allow this, which makes them very
|
|
hard to use if you're trying to define interfaces like "Read-only Mapping"
|
|
as a subset of "Mapping Object".
|