[Zodb-checkins] CVS: Packages/ZConfig/doc - zconfig.tex:

Fred L. Drake, Jr. fred@zope.com
Fri, 20 Dec 2002 15:59:05 -0500

Update of /cvs-repository/Packages/ZConfig/doc
In directory cvs.zope.org:/tmp/cvs-serv23088

Modified Files:
      Tag: zconfig-schema-devel-branch
Log Message:
Documented the ZConfig.datatypes module.

=== Packages/ZConfig/doc/zconfig.tex => ===
--- Packages/ZConfig/doc/zconfig.tex:	Fri Dec 20 14:00:05 2002
+++ Packages/ZConfig/doc/zconfig.tex	Fri Dec 20 15:59:04 2002
@@ -220,7 +220,7 @@
 \end{verbatim} %$ <-- bow to font-lock
-\section{Standard \module{ZConfig} Datatypes}
+\section{Standard \module{ZConfig} Datatypes\label{standard-datatypes}}
 There are a number of data types which can be identified using the
 \code{datatype} attribute on \code{key}, \code{multikey},
@@ -661,6 +661,90 @@
   for delegates before being called on the delegating section.)  The
   default implementation does nothing.
+\section{\module{ZConfig.datatypes} --- Default data type registry}
+\modulesynopsis{Default implementation of a data type registry}
+The \module{ZConfig.datatypes} module provides the implementation of
+the default data type registry and all the standard data types
+supported by \module{ZConfig}.  A number of convenience classes are
+also provided to assist in the creation of additional datatypes.
+A \dfn{datatype registry} is an object that provides conversion
+functions for data types.  The interface for a registry is fairly
+A \dfn{conversion function} is any callable object that accepts a
+single argument and returns a suitable value, or raises an exception
+if the input value is not acceptable.  \exception{ValueError} is the
+preferred exception for disallowed inputs, but any other exception
+will be properly propogated.
+  Implementation of a simple type registry.  If given, \var{stock}
+  should be a mapping which defines the ``built-in'' data types for
+  the registry; if omitted or \code{None}, the standard set of data
+  types is used (see section~\ref{standard-datatypes}, ``Standard
+  \module{ZConfig} Datatypes'').
+\class{Registry} objects have the following methods:
+  Return the type conversion routine for \var{name}.  If the
+  conversion function cannot be found, an (unspecified) exception is
+  raised.  If the name is not provided in the stock set of data types
+  by this registry and has not otherwise been registered, this method
+  uses the \method{search()} method to load the conversion function.
+  This is the only method the \module{ZConfig.schema} module requires.
+\begin{methoddesc}{register}{name, conversion}
+  Registery the data type name \var{name} to use the conversion
+  function \var{conversion}.  If \var{name} is already registered or
+  provided as a stock data type, \exception{ValueError} is raised
+  (this includes the case when \var{name} was found using the
+  \method{search()} method).
+  This is a helper method for the default implementation of the
+  \method{get()} method.  If \var{name} is a Python dotted-name, this
+  method loads the value for the name by dynamically importing the
+  containing module and extracting the value of the name.  The name
+  must refer to a usable conversion function.
+The following classes are provided to define conversion functions:
+  Simple memoization for potentially expensive conversions.  This
+  conversion helper caches each successful conversion for re-use at a
+  later time; failed conversions are not cached in any way, since it
+  is difficult to raise a meaningful excpetion providing information
+  about the specific failure.
+                                          min\optional{, max}}}
+  Helper that performs range checks on the result of another
+  conversion.  Values passed to instances of this conversion are
+  converted using \var{conversion} and then range checked.  \var{min}
+  and \var{max}, if given and not \code{None}, are the inclusive
+  endpoints of the allowed range.  Values returned by \var{conversion}
+  which lay outside the range described by \var{min} and \var{max}
+  cause \exception{ValueError} to be raised.
+  Conversion that checks that the input matches the regular expression
+  \var{regex}.  If it matches, returns the input, otherwise raises
+  \exception{ValueError}.
 \section{\module{ZConfig.substitution} --- String substitution}