Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZODB
Commits
b5ef2ef7
Commit
b5ef2ef7
authored
Oct 09, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a brief description of the replacement syntax and some example of
using the ZConfig.Interpolation module.
parent
0cc3cb81
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
3 deletions
+54
-3
doc/ZConfig/zconfig.tex
doc/ZConfig/zconfig.tex
+54
-3
No files found.
doc/ZConfig/zconfig.tex
View file @
b5ef2ef7
...
...
@@ -74,7 +74,29 @@
This module provides a basic substitution facility similar to that
found in the Bourne shell (
\program
{
sh
}
on most
\UNIX
{}
platforms).
XXX need to explain the syntax here
The replacements supported by this module include:
\begin{tableiii}
{
l|l|c
}{
code
}{
Source
}{
Replacement
}{
Notes
}
\lineiii
{
\$\$
}{
\code
{
\$
}}{
(1)
}
\lineiii
{
\$\var
{
name
}}{
The result of looking up
\var
{
name
}}{
(2)
}
\lineiii
{
\$\{\var
{
name
}
\}
}{
The result of looking up
\var
{
name
}}{}
\end{tableiii}
\noindent
Notes:
\begin{description}
\item
[(1)]
This is different from the Bourne shell, which uses
\code
{
\textbackslash\$
}
to generate a
\character
{
\$
}
in
the result text. This difference avoids having as many
special characters in the syntax.
\item
[(2)]
Any character which immediately follows
\var
{
name
}
may
not be a valid character in a name.
\end{description}
In each case,
\var
{
name
}
is a non-empty sequence of alphanumeric and
underscore characters not starting with a digit. If there is not
a replacement for
\var
{
name
}
, it is replaced with an empty string.
For these functions, the
\var
{
mapping
}
argument can be a
\class
{
dict
}
,
or any type that supports the
\method
{
get()
}
method of the mapping
...
...
@@ -89,13 +111,16 @@ protocol.
\begin{funcdesc}
{
get
}{
mapping, name
\optional
{
, default
}}
Return the value for
\var
{
name
}
from
\var
{
mapping
}
, interpolating
values recursively if needed. Raises
\exception
{
InterpolationSyntaxError
}
if there are malformed
values recursively if needed. If
\var
{
name
}
cannot be found in
\var
{
mapping
}
,
\var
{
default
}
is returned without being
interpolated.
Raises
\exception
{
InterpolationSyntaxError
}
if there are malformed
constructs in
\var
{
s
}
, or
\exception
{
InterpolationRecursionError
}
if
any name expands to include a reference to itself either directly or
indirectly.
\end{funcdesc}
The following exceptions are defined:
\begin{excdesc}
{
InterpolationError
}
Base class for errors raised by the
\module
{
ZConfig.Interpolation
}
...
...
@@ -116,4 +141,30 @@ protocol.
for which an recursive reference was detected.
\end{excdesc}
\subsection
{
Examples
}
These examples show how
\function
{
get()
}
and
\function
{
interpolate()
}
differ.
\begin{verbatim}
>>> from ZConfig.Interpolation import get, interpolate
>>> d =
{
'name': 'value',
... 'top': '
$
middle',
... 'middle' : 'bottom'
}
>>>
>>> interpolate
(
'
$
name', d)
'value'
>>> interpolate('
$
top', d
)
'
$
middle'
>>>
>>> get(d, 'name')
'value'
>>> get(d, 'top')
'bottom'
>>> get(d, 'missing', '
$
top'
)
'
$
top'
\end{verbatim}
\end{document}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment