1.1.8.1 Defining a protocol based on a URI or UUID

protocolForURI( uri)
New in version 0.9.1. Return a protocol object that represents the supplied URI or UUID string. It is guaranteed that you will receive the same protocol object if you call this routine more than once with equal strings. This behavior is preserved even across pickling and unpickling of the returned protocol object.

The purpose of this function is to permit modules to refer to protocols defined in another module, that may or may not be present at runtime. To do this, a protocol author can declare that their protocol is equivalent to a URI string:


\begin{verbatim}from protocols import advise, Interface, protocolForURI
\par
cla...
...entProtocols = [protocolForURI(''some URI string'')]
)
...

Then, if someone wishes to use this protocol without importing ISomething (and thereby becoming dependent on the module that provides it), they can do something like:


\begin{verbatim}from protocols import advise, protocolForURI
\par
class MyClass:...
...e(
provides = [protocolForURI(''some URI string'')]
)
...

Thus, instances of MyClass will be considered to support ISomething, if needed. But, if ISomething doesn't exist, no error occurs.