Document the extension registry API.

Remove mention of Twisted (they don't want it).
This commit is contained in:
Guido van Rossum 2003-02-04 19:28:16 +00:00
parent 8787ee145b
commit f95c17f368
1 changed files with 37 additions and 6 deletions

View File

@ -533,9 +533,9 @@ The extension registry
need to have some out-of-band mechanism to agree on the mapping
between extension codes and names.
Second, some large Python projects (e.g. Zope or Twisted) can be
assigned a range of extension codes outside the "private use"
range that they can assign as they see fit.
Second, some large Python projects (e.g. Zope) can be assigned a
range of extension codes outside the "private use" range that they
can assign as they see fit.
The extension registry is defined as a mapping between extension
codes and names. When an extension code is unpickled, it ends up
@ -556,14 +556,45 @@ The extension registry
128 191 64 Reserved for Zope 3
192 239 48 Reserved for 3rd parties
240 255 16 Reserved for private use (will never be assigned)
256 Max Max Reserved for future assignment
256 MAX MAX Reserved for future assignment
'Max' stands for 2147483647, or 2**31-1. This is a hard
limitation of the protocol as currently defined.
MAX stands for 2147483647, or 2**31-1. This is a hard limitation
of the protocol as currently defined.
At the moment, no specific extension codes have been assigned yet.
Extension registry API
The extension registry is maintained as private global variables
in the copy_reg module. The following three functions are defined
in this module to manipulate the registry:
add_extension(module, name, code)
Register an extension code. The module and name arguments
must be strings; code must be an int in the inclusive range 1
through MAX. This must either register a new (module, name)
pair to a new code, or be a redundant repeat of a previous
call that was not canceled by a remove_extension() call; a
(module, name) pair may not be mapped to more than one code,
nor may a code be mapped to more than one (module, name)
pair. (XXX Aliasing may actually cause as problem for this
requirement; we'll see as we go.)
remove_extension(module, name, code)
Arguments are as for add_extension(). Remove a previously
registered mapping between (module, name) and code.
clear_extension_cache()
The implementation of extension codes may use a cache to speed
up loading objects that are named frequently. This cache can
be emptied (removing references to cached objects) by calling
this method.
Note that the API does not enforce the standard range assignments.
It is up to applications to respect these.
TBD
The rest of this PEP is still under construction!