1.1.8.1 Defining a protocol based on a URI or UUID
Description: Defining a protocol based on a URI or UUID
Keywords: ref

###
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:

      from protocols import advise, Interface, protocolForURI

      class ISomething(Interface):
          advise(
              equivalentProtocols = [protocolForURI("some URI string")]
          )
          # etc...

  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:

      from protocols import advise, protocolForURI

      class MyClass:
          advise(
              provides = [protocolForURI("some URI string")]
          )
          # etc...

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