Commit 1f7fd3ac authored by Guido van Rossum's avatar Guido van Rossum

Adding AMK's guide (merge)

parent 5c0bad8d
PYTHONSRC=$$HOME/projects/python
TEX_FILES = gfdl.tex introduction.tex modules.tex prog-zodb.tex \
storages.tex transactions.tex zeo.tex zodb.tex
MKHOWTO=$(PYTHONSRC)/Doc/tools/mkhowto
zodb.dvi: $(TEX_FILES)
$(MKHOWTO) --dvi zodb.tex
html:
-rm -rf zodb
$(MKHOWTO) --html --iconserver=/python/writing/icons zodb.tex
# rm -f /home/amk/www/zodb/guide/*
# cp -p zodb/* /home/amk/www/zodb/guide/
This directory contains Andrew Kuchling's programmers guide to ZODB
and ZEO. It is taken from Andrew's zodb.sf.net project on
SourceForge. The SF version should be considered the canonical
version, so don't make edits here for now.
Eventually, we'll finish merging the two projects and then the version
here will be the canonical one. For now, we have to manually keep the
two directories in sync.
Update text to use BTrees, not BTree
Write section on __setstate__
Connection.sync seems to work now; note this
Continue working on it
Suppress the full GFDL text in the PDF/PS versions
% Administration
% Importing and exporting data
% Disaster recovery/avoidance
% Security
import sys, time, os, random
from ZEO import ClientStorage
import ZODB
from ZODB.POSException import ConflictError
from Persistence import Persistent
import BTree
class ChatSession(Persistent):
"""Class for a chat session.
Messages are stored in a B-tree, indexed by the time the message
was created. (Eventually we'd want to throw messages out,
add_message(message) -- add a message to the channel
new_messages() -- return new messages since the last call to
this method
"""
def __init__(self, name):
"""Initialize new chat session.
name -- the channel's name
"""
self.name = name
# Internal attribute: _messages holds all the chat messages.
self._messages = BTree.BTree()
def new_messages(self):
"Return new messages."
# self._v_last_time is the time of the most recent message
# returned to the user of this class.
if not hasattr(self, '_v_last_time'):
self._v_last_time = 0
new = []
T = self._v_last_time
for T2, message in self._messages.items():
if T2 > T:
new.append( message )
self._v_last_time = T2
return new
def add_message(self, message):
"""Add a message to the channel.
message -- text of the message to be added
"""
while 1:
try:
now = time.time()
self._messages[ now ] = message
get_transaction().commit()
except ConflictError:
# Conflict occurred; this process should pause and
# wait for a little bit, then try again.
time.sleep(.2)
pass
else:
# No ConflictError exception raised, so break
# out of the enclosing while loop.
break
# end while
def get_chat_session(conn, channelname):
"""Return the chat session for a given channel, creating the session
if required."""
# We'll keep a B-tree of sessions, mapping channel names to
# session objects. The B-tree is stored at the ZODB's root under
# the key 'chat_sessions'.
root = conn.root()
if not root.has_key('chat_sessions'):
print 'Creating chat_sessions B-tree'
root['chat_sessions'] = BTree.BTree()
get_transaction().commit()
sessions = root['chat_sessions']
# Get a session object corresponding to the channel name, creating
# it if necessary.
if not sessions.has_key( channelname ):
print 'Creating new session:', channelname
sessions[ channelname ] = ChatSession(channelname)
get_transaction().commit()
session = sessions[ channelname ]
return session
if __name__ == '__main__':
if len(sys.argv) != 2:
print 'Usage: %s <channelname>' % sys.argv[0]
sys.exit(0)
storage = ClientStorage.ClientStorage( ('localhost', 9672) )
db = ZODB.DB( storage )
conn = db.open()
s = session = get_chat_session(conn, sys.argv[1])
messages = ['Hi.', 'Hello', 'Me too', "I'M 3L33T!!!!"]
while 1:
# Send a random message
msg = random.choice(messages)
session.add_message( '%s: pid %i' % (msg,os.getpid() ))
# Display new messages
for msg in session.new_messages():
print msg
# Wait for a few seconds
pause = random.randint( 1, 4 )
time.sleep( pause )
% gfdl.tex
% This file is a chapter. It must be included in a larger document to work
% properly.
\section{GNU Free Documentation License}
Version 1.1, March 2000\\
Copyright $\copyright$ 2000 Free Software Foundation, Inc.\\
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\\
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
\subsection*{Preamble}
The purpose of this License is to make a manual, textbook, or other
written document ``free'' in the sense of freedom: to assure everyone
the effective freedom to copy and redistribute it, with or without
modifying it, either commercially or noncommercially. Secondarily,
this License preserves for the author and publisher a way to get
credit for their work, while not being considered responsible for
modifications made by others.
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
\subsection{Applicability and Definitions}
This License applies to any manual or other work that contains a
notice placed by the copyright holder saying it can be distributed
under the terms of this License. The ``Document'', below, refers to any
such manual or work. Any member of the public is a licensee, and is
addressed as ``you''.
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
A ``Secondary Section'' is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (For example, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, whose contents can be viewed and edited directly and
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup has been designed to thwart or discourage
subsequent modification by readers is not Transparent. A copy that is
not ``Transparent'' is called ``Opaque''.
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, \LaTeX~input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML designed for human modification. Opaque formats include
PostScript, PDF, proprietary formats that can be read and edited only
by proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML produced by some word processors for output
purposes only.
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
\subsection{Verbatim Copying}
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
\subsection{Copying in Quantity}
If you publish printed copies of the Document numbering more than 100,
and the Document's license notice requires Cover Texts, you must enclose
the copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a publicly-accessible computer-network location containing a complete
Transparent copy of the Document, free of added material, which the
general network-using public has access to download anonymously at no
charge using public-standard network protocols. If you use the latter
option, you must take reasonably prudent steps, when you begin
distribution of Opaque copies in quantity, to ensure that this
Transparent copy will remain thus accessible at the stated location
until at least one year after the last time you distribute an Opaque
copy (directly or through your agents or retailers) of that edition to
the public.
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
\subsection{Modifications}
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
\begin{itemize}
\item Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
\item List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has less than five).
\item State on the Title page the name of the publisher of the
Modified Version, as the publisher.
\item Preserve all the copyright notices of the Document.
\item Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
\item Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
\item Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
\item Include an unaltered copy of this License.
\item Preserve the section entitled ``History'', and its title, and add to
it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
\item Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
\item In any section entitled ``Acknowledgements'' or ``Dedications'',
preserve the section's title, and preserve in the section all the
substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
\item Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
\item Delete any section entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
\item Do not retitle any existing section as ``Endorsements''
or to conflict in title with any Invariant Section.
\end{itemize}
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
You may add a section entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties -- for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
\subsection{Combining Documents}
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice.
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
In the combination, you must combine any sections entitled ``History''
in the various original documents, forming one section entitled
``History''; likewise combine any sections entitled ``Acknowledgements'',
and any sections entitled ``Dedications''. You must delete all sections
entitled ``Endorsements.''
\subsection{Collections of Documents}
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
\subsection{Aggregation With Independent Works}
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, does not as a whole count as a Modified Version
of the Document, provided no compilation copyright is claimed for the
compilation. Such a compilation is called an ``aggregate'', and this
License does not apply to the other self-contained works thus compiled
with the Document, on account of their being thus compiled, if they
are not themselves derivative works of the Document.
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one quarter
of the entire aggregate, the Document's Cover Texts may be placed on
covers that surround only the Document within the aggregate.
Otherwise they must appear on covers around the whole aggregate.
\subsection{Translation}
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License provided that you also include the
original English version of this License. In case of a disagreement
between the translation and the original English version of this
License, the original English version will prevail.
\subsection{Termination}
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
\subsection{Future Revisions of This Licence}
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
\url{http://www.gnu.org/copyleft/}.
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
\subsection*{ADDENDUM: How to use this License for your documents}
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
\begin{quote}
Copyright $\copyright$ YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
\end{quote}
If you have no Invariant Sections, write ``with no Invariant Sections''
instead of saying which ones are invariant. If you have no
Front-Cover Texts, write ``no Front-Cover Texts'' instead of
``Front-Cover Texts being LIST''; likewise for Back-Cover Texts.
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
% Indexing Data
% BTrees
% Full-text indexing
%Introduction
% What is ZODB?
% What is ZEO?
% OODBs vs. Relational DBs
% Other OODBs
\section{Introduction}
This guide explains how to write Python programs that use the Z Object
Database (ZODB) and Zope Enterprise Objects (ZEO). The latest version
of the guide is always available at
\url{http://www.amk.ca/zodb/guide/}.
\subsection{What is the ZODB?}
The ZODB is a persistence system for Python objects. Persistent
programming languages provide facilities that automatically write
objects to disk and read them in again when they're required by a
running program. By installing the ZODB, you add such facilities to
Python.
It's certainly possible to build your own system for making Python
objects persistent. The usual starting points are the \module{pickle}
module, for converting objects into a string representation, and
various database modules, such as the \module{gdbm} or \module{bsddb}
modules, that provide ways to write strings to disk and read them
back. It's straightforward to combine the \module{pickle} module and
a database module to store and retrieve objects, and in fact the
\module{shelve} module, included in Python's standard library, does
this.
The downside is that the programmer has to explicitly manage objects,
reading an object when it's needed and writing it out to disk when the
object is no longer required. The ZODB manages objects for you,
keeping them in a cache and writing them out if they haven't been
accessed in a while.
\subsection{OODBs vs. Relational DBs}
Another way to look at it is that the ZODB is a Python-specific
object-oriented database (OODB). Commercial object databases for C++
or Java often require that you jump through some hoops, such as using
a special preprocessor or avoiding certain data types. As we'll see,
the ZODB has some hoops of its own to jump through, but in comparison
the naturalness of the ZODB is astonishing.
Relational databases (RDBs) are far more common than OODBs.
Relational databases store information in tables; a table consists of
any number of rows, each row containing several columns of
information. (Rows are more formally called relations, which is where
the term ``relational database'' originates.)
Let's look at a concrete example. The example comes from my day job
working for the MEMS Exchange, in a greatly simplified version. The
job is to track process runs, which are lists of manufacturing steps
to be performed in a semiconductor fab. A run is owned by a
particular user, and has a name and assigned ID number. Runs consist
of a number of operations; an operation is a single step to be
performed, such as depositing something on a wafer or etching
something off it.
Operations may have parameters, which are additional information
required to perform an operation. For example, if you're depositing
something on a wafer, you need to know two things: 1) what you're
depositing, and 2) how much should be deposited. You might deposit
100 microns of silicon oxide, or 1 micron of copper.
Mapping these structures to a relational database is straightforward:
\begin{verbatim}
CREATE TABLE runs (
int run_id,
varchar owner,
varchar title,
int acct_num,
primary key(run_id)
);
CREATE TABLE operations (
int run_id,
int step_num,
varchar process_id,
PRIMARY KEY(run_id, step_num),
FOREIGN KEY(run_id) REFERENCES runs(run_id),
);
CREATE TABLE parameters (
int run_id,
int step_num,
varchar param_name,
varchar param_value,
PRIMARY KEY(run_id, step_num, param_name)
FOREIGN KEY(run_id, step_num)
REFERENCES operations(run_id, step_num),
);
\end{verbatim}
In Python, you would write three classes named \class{Run},
\class{Operation}, and \class{Parameter}. I won't present code for
defining these classes, since that code is uninteresting at this
point. Each class would contain a single method to begin with, an
\method{__init__} method that assigns default values, such as 0 or
\code{None}, to each attribute of the class.
It's not difficult to write Python code that will create a \class{Run}
instance and populate it with the data from the relational tables;
with a little more effort, you can build a straightforward tool,
usually called an object-relational mapper, to do this automatically.
(See
\url{http://www.amk.ca/python/unmaintained/ordb.html} for a quick hack
at a Python object-relational mapper, and
\url{http://www.python.org/workshops/1997-10/proceedings/shprentz.html}
for Joel Shprentz's more successful implementation of the same idea;
Unlike mine, Shprentz's system has been used for actual work.)
However, it is difficult to make an object-relational mapper
reasonably quick; a simple-minded implementation like mine is quite
slow because it has to do several queries to access all of an object's
data. Higher performance object-relational mappers cache objects to
improve performance, only performing SQL queries when they actually
need to.
That helps if you want to access run number 123 all of a sudden. But
what if you want to find all runs where a step has a parameter named
'thickness' with a value of 2.0? In the relational version, you have
two unappealing choices:
\begin{enumerate}
\item Write a specialized SQL query for this case: \code{SELECT run_id
FROM operations WHERE param_name = 'thickness' AND param_value = 2.0}
If such queries are common, you can end up with lots of specialized
queries. When the database tables get rearranged, all these queries
will need to be modified.
\item An object-relational mapper doesn't help much. Scanning
through the runs means that the the mapper will perform the required
SQL queries to read run \#1, and then a simple Python loop can check
whether any of its steps have the parameter you're looking for.
Repeat for run \#2, 3, and so forth. This does a vast
number of SQL queries, and therefore is incredibly slow.
\end{enumerate}
An object database such as ZODB simply stores internal pointers from
object to object, so reading in a single object is much faster than
doing a bunch of SQL queries and assembling the results. Scanning all
runs, therefore, is still inefficient, but not grossly inefficient.
\subsection{What is ZEO?}
The ZODB comes with a few different classes that implement the
\class{Storage} interface. Such classes handle the job of
writing out Python objects to a physical storage medium, which can be
a disk file (the \class{FileStorage} class), a BerkeleyDB file
(\class{BerkeleyStorage}), a relational database
(\class{DCOracleStorage}), or some other medium. ZEO adds
\class{ClientStorage}, a new \class{Storage} that doesn't write to
physical media but just forwards all requests across a network to a
server. The server, which is running an instance of the
\class{StorageServer} class, simply acts as a front-end for some
physical \class{Storage} class. It's a fairly simple idea, but as
we'll see later on in this document, it opens up many possibilities.
\subsection{About this guide}
The primary author of this guide works on a project which uses the
ZODB and ZEO as its primary storage technology. We use the ZODB to
store process runs and operations, a catalog of available processes,
user information, accounting information, and other data. Part of the
goal of writing this document is to make our experience more widely
available. A few times we've spent hours or even days trying to
figure out a problem, and this guide is an attempt to gather up the
knowledge we've gained so that others don't have to make the same
mistakes we did while learning.
This document will always be a work in progress. If you wish to
suggest clarifications or additional topics, please send your comments to
\email{akuchlin@mems-exchange.org}.
\subsection{Acknowledgements}
I'd like to thank the people who've pointed out inaccuracies and bugs,
offered suggestions on the text, or proposed new topics that should be
covered: Jeff Bauer, Willem Broekema, Thomas Guettler,
Chris McDonough, George Runyan.
% links.tex
% Collection of relevant links
\section{Resources}
ZODB HOWTO, by Michel Pelletier:
\\
Goes into slightly more detail about the rules for writing applications using the ZODB.
\\
\url{http://www.zope.org/Members/michel/HowTos/ZODB-How-To}
Introduction to the Zope Object Database, by Jim Fulton:
\\
Goes into much greater detail, explaining advanced uses of the ZODB and
how it's actually implemented. A definitive reference, and highly recommended.
\\
\url{http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html}
Download link for ZEO: \\
\url{http://www.zope.org/Products/ZEO/}
% Related Modules
% PersistentMapping
% PersistentList
% BTree
% Catalog
\section{Related Modules}
The ZODB package includes a number of related modules that provide
useful data types such as BTrees or full-text indexes.
\subsection{\module{ZODB.PersistentMapping}}
The \class{PersistentMapping} class is a wrapper for mapping objects
that will set the dirty bit when the mapping is modified by setting or
deleting a key.
\begin{funcdesc}{PersistentMapping}{container = \{\}}
Create a \class{PersistentMapping} object that wraps the
mapping object \var{container}. If you don't specify a
value for \var{container}, a regular Python dictionary is used.
\end{funcdesc}
\class{PersistentMapping} objects support all the same methods as
Python dictionaries do.
\subsection{\module{ZODB.PersistentList}}
The \class{PersistentList} class is a wrapper for mutable sequence objects,
much as \class{PersistentMapping} is a wrapper for mappings.
\begin{funcdesc}{PersistentList}{initlist = []}
Create a \class{PersistentList} object that wraps the
mutable sequence object \var{initlist}. If you don't specify a
value for \var{initlist}, a regular Python list is used.
\end{funcdesc}
\class{PersistentList} objects support all the same methods as
Python lists do.
\subsection{B-tree Modules}
%here's one: how does one implement searching? i would have expected the
%btree objects to have ``find key nearest to this'' and ``next'' methods,
%(like bsddb's set_location)...
%
% -- erno
When programming with the ZODB, Python dictionaries aren't always what
you need. The most important case is where you want to store a very
large mapping. When a Python dictionary is accessed in a ZODB, the
whole dictionary has to be unpickled and brought into memory. If
you're storing something very large, such as a 100,000-entry user
database, unpickling such a large object will be slow. B-trees are a
balanced tree data structure that behave like a mapping but distribute
keys throughout a number of tree nodes. Nodes are then only unpickled
and brought into memory as they're accessed, so the entire tree
doesn't have to occupy memory (unless you really are touching every
single key).
There are four different BTree modules provided. One of them, the
\module{BTree} module, provides the most general data type; the keys
and values in the B-tree can be any Python object. Some specialized B-tree
modules require that the keys, and perhaps even the values, to be of a
certain type, and provide faster performance because of this limitation.
\begin{itemize}
\item[ \module{IOBTree} ] requires the keys to be integers.
The module name reminds you of this; the \module{IOBTree} module
maps Integers to Objects.
\item[ \module{OIBTree} ] requires the values to be integers,
mapping Objects to Integers.
\item[ \module{IIBTree} ] is strictest, requiring that both keys and values must be integers.
\end{itemize}
To use a B-tree, simply import the desired module and call the
constructor, always named \function{BTree()}, to get a B-tree
instance, and then use it like any other mapping:
\begin{verbatim}
import IIBTree
iimap = IIBTree.BTree()
iimap[1972] = 27
\end{verbatim}
%ZODB Programming
% How ZODB works (ExtensionClass, dirty bits)
% Installing ZODB
% Rules for Writing Persistent Classes
\section{ZODB Programming}
\subsection{Installing ZODB}
The ZODB forms part of Zope, but it's difficult and somewhat painful
to extract the bits from Zope needed to support just the ZODB.
Therefore I've assembled a distribution containing only the packages
required to use the ZODB and ZEO, so you can install it and start
programming right away.
To download the distribution, go to my ZODB page at
\url{http://www.amk.ca/zodb/}.
The distribution is still experimental, so don't be surprised if the
installation process runs into problems. Please inform me of any
difficulties you encounter.
\subsubsection{Requirements}
You'll need Python, of course; version 1.5.2 works with some fixes,
and it also works with Python 2.0, which is what I primarily use.
The code is packaged using Distutils, the new distribution tools for
Python introduced in Python 2.0. If you're using 1.5.2, first you'll
have to get the latest Distutils release from the Distutils SIG page
at \url{http://www.python.org/sigs/distutils-sig/download.html} and
install it. This is simply a matter of untarring or unzipping the
release package, and then running \code{python setup.py install}.
If you're using 1.5.2 and have installed previous versions of the
Distutils, be sure to get the very latest version, since developing
the ZODB distribution turned up some bugs along the way. If you
encounter problems compiling \file{ZODB/TimeStamp.c} or your compiler reports
an error like ``Can't create build/temp.linux2/ExtensionClass.o: No
such file or directory'', you need an updated version. Old versions of
Distutils have two bugs which affect the setup scripts. First, for a
long time the \code{define_macros} keyword in setup.py files didn't work due
to a Distutils bug, so I hacked TimeStamp.c in earlier releases. The
Distutils have since been fixed, and the hack became unnecessary, so I
removed it. Second, the code that creates directories tries to be
smart and caches them to save time by not trying to create a directory
twice, but this code was broken in old versions.
You'll need a C compiler to build the packages, because there are
various C extension modules. At the moment no one is making Windows
binaries available, so you'll need a Windows development environment to use the
\subsubsection{Installing the Packages}
Download the ZODB tarball containing all the packages for both ZODB
and ZEO from \url{http://www.amk.ca/files/zodb/}.
To build the packages, you must go into the individual directories and
build and install them one by one. They should be built and installed
in this order:
\begin{enumerate}
\item \code{zodb-basic}
\item ExtensionClass
\item ZODB
\item \code{BTree} and \code{BTrees}
\item ZEO
\end{enumerate}
In particular, you must install ExtensionClass before building the
ZODB package; otherwise, the compilation in the ZODB package will die
complaining that it can't find ExtensionClass.h. You can manually
hack the \#include path to make it work without installing
ExtensionClass first, but that's a bit hackish.
If you encounter any problems, please let me know at
\email{akuchlin@mems-exchange.org}.
\subsection{How ZODB Works}
The ZODB is conceptually simple. Python classes subclass a
\class{Persistent} class to become ZODB-aware.
Instances of persistent objects are brought in from a permanent
storage medium, such as a disk file, when the program needs them, and
remain cached in RAM. The ZODB traps modifications to objects, so
that when a statement such as \code{obj.size = 1} is executed, the
modified object is marked as ``dirty''. On request, any dirty objects
are written out to permanent storage; this is called committing a
transaction. Transactions can also be aborted or rolled back, which
results in any changes being discarded, dirty objects reverting to
their initial state before the transaction began.
The term ``transaction'' has a specific technical meaning in computer
science. It's extremely important that the contents of a database
don't get corrupted by software or hardware crashes, and most database
software offers protection against such corruption by supporting four
useful properties, Atomicity, Consistency, Isolation, and Durability.
In computer science jargon these four terms are collectively dubbed
the ACID properties, forming an acronym from their names. The
definitions of the ACID properties are:
\begin{itemize}
\item[Atomicity] means that any changes to data made during a transaction
are all-or-nothing. Either all the changes are applied, or none of
them are. If a program makes a bunch of modifications and then
crashes, the database won't be partially modified, potentially leaving
the data in an inconsistent state; instead all the changes will be
forgotten. That's bad, but it's better than having a
partially-applied modification put the database into an inconsistent
state.
\item[Consistency] means that the data cannot be placed into a
logically invalid state; sanity checks can be written and enforced.
Usually this is done by defining a database schema, and requiring the
data always matches the schema. For example, this might enforce that
the \code{order_number} attribute is always an integer, and not a
string, tuple, or other object.
\item[Isolation] means that two programs or threads running in two
different transactions cannot see each other's changes until they
commit their transactions.
\item[Durability] means that once a transaction has been committed,
a subsequent crash will not cause any data to be lost or corrupted.
\end{itemize}
The ZODB provides 3 of the ACID properties. Only Consistency is not
supported; the ZODB has no notion of a database schema, and therefore
has no way of enforcing consistency with a schema.
\subsection{Opening a ZODB}
There are 3 main interfaces supplied by the ZODB:
\class{Storage}, \class{DB}, and \class{Connection} classes. The
\class{DB} and \class{Connection} interfaces both have single
implementations, but there are several different classes that
implement the \class{Storage} interface.
\begin{itemize}
\item \class{Storage} classes are the lowest layer, and handle
storing and retrieving objects from some form of long-term storage.
A few different types of Storage have been written, such as
\class{FileStorage}, which uses regular disk files, and
\class{BerkeleyStorage}, which uses Sleepycat Software's BerkeleyDB
database. You could write a new Storage that stored objects in a
relational database or Metakit file, for example, if that would
better suit your application. Two example storages,
\class{DemoStorage} and \class{MappingStorage}, are available to use
as models if you want to write a new Storage.
\item The \class{DB} class sits on top of a storage, and mediates the
interaction between several connections. One \class{DB} instance is
created per process.
\item Finally, the \class{Connection} class caches objects, and moves
them into and out of object storage. A multi-threaded program can
open a separate \class{Connection} instance for each thread.
Different threads can then modify objects and commit their
modifications independently.
\end{itemize}
Preparing to use a ZODB requires 3 steps: you have to open the
\class{Storage}, then create a \class{DB} instance that uses the \class{Storage}, and then get
a \class{Connection} from the \class{DB instance}. All this is only a few lines of
code:
\begin{verbatim}
from ZODB import FileStorage, DB
storage = FileStorage.FileStorage('/tmp/test-filestorage.fs')
db = DB(storage)
conn = db.open()
\end{verbatim}
Note that you can use a completely different data storage mechanism by
changing the first line that opens a \class{Storage}; the above example uses a
\class{FileStorage}. In section~\ref{zeo}, ``How ZEO Works'',
you'll see how ZEO uses this flexibility to good effect.
\subsection{Writing a Persistent Class}
Making a Python class persistent is quite simple; it simply needs to
subclass from the \class{Persistent} class, as shown in this example:
\begin{verbatim}
import ZODB
from Persistence import Persistent
class User(Persistent):
pass
\end{verbatim}
The apparently unnecessary \code{import ZODB} statement is
needed for the following \code{from...import} statement to work
correctly, since the ZODB code does some magical tricks with
importing.
For simplicity, in the examples the \class{User} class will
simply be used as a holder for a bunch of attributes. Normally the
class would define various methods that add functionality, but that
has no impact on the ZODB's treatment of the class.
The ZODB uses persistence by reachability; starting from a set of root
objects, all the attributes of those objects are made persistent,
whether they're simple Python data types or class instances. There's
no method to explicitly store objects in a ZODB database; simply
assign them as an attribute of an object, or store them in a mapping,
that's already in the database. This chain of containment must
eventually reach back to the root object of the database.
As an example, we'll create a simple database of users that allows
retrieving a \class{User} object given the user's ID. First, we
retrieve the primary root object of the ZODB using the \method{root()}
method of the \class{Connection} instance. The root object behaves
like a Python dictionary, so you can just add a new key/value pair for
your application's root object. We'll insert a \class{BTree} object
that will contain all the \class{User} objects. (The
\class{BTree} module is also included as part of Zope.)
\begin{verbatim}
dbroot = conn.root()
# Ensure that a 'userdb' key is present
# in the root
if not dbroot.has_key('userdb'):
import BTree
dbroot['userdb'] = BTree.BTree()
userdb = dbroot['userdb']
\end{verbatim}
Inserting a new user is simple: create the \class{User} object, fill
it with data, insert it into the \class{BTree} instance, and commit
this transaction.
\begin{verbatim}# Create new User instance
newuser = User()
# Add whatever attributes you want to track
newuser.id = 'amk'
newuser.first_name = 'Andrew' ; newuser.last_name = 'Kuchling'
...
# Add object to the BTree, keyed on the ID
userdb[newuser.id] = newuser
# Commit the change
get_transaction().commit()
\end{verbatim}
When you import the ZODB package, it adds a new function,
\function{get_transaction()}, to Python's collection of built-in
functions. \function{get_transaction()} returns a \class{Transaction}
object, which has two important methods: \method{commit()} and
\method{abort()}. \method{commit()} writes any modified objects
to disk, making the changes permanent, while \method{abort()} rolls
back any changes that have been made, restoring the original state of
the objects. If you're familiar with database transactional
semantics, this is all what you'd expect.
Because the integration with Python is so complete, it's a lot like
having transactional semantics for your program's variables, and you
can experiment with transactions at the Python interpreter's prompt:
\begin{verbatim}>>> newuser
<User instance at 81b1f40>
>>> newuser.first_name # Print initial value
'Andrew'
>>> newuser.first_name = 'Bob' # Change first name
>>> newuser.first_name # Verify the change
'Bob'
>>> get_transaction().abort() # Abort transaction
>>> newuser.first_name # The value has changed back
'Andrew'
\end{verbatim}
\subsection{Rules for Writing Persistent Classes}
Practically all persistent languages impose some restrictions on
programming style, warning against constructs they can't handle or
adding subtle semantic changes, and the ZODB is no exception.
Happily, the ZODB's restrictions are fairly simple to understand, and
in practice it isn't too painful to work around them.
The summary of rules is as follows:
\begin{itemize}
\item If you modify a mutable object that's the value of an object's
attribute, the ZODB can't catch that, and won't mark the object as
dirty.
The solution is to either set the dirty bit yourself when you modify
mutable objects, or use a wrapper for Python's lists and dictionaries
(\class{PersistentList},
\class{PersistentMapping})
that will set the dirty bit properly.
\item Certain of Python's special methods don't work when they're
defined on ExtensionClasses. The most important ones are the
\method{__cmp__} method, and the reversed versions of binary
arithmetic operations: \method{__radd__}, \method{__rsub__}, and so
forth.
\item Python's built-in \function{isinstance()} and \function{issubclass()}
functions don't work properly on ExtensionClasses. Solution: use
custom \function{isinstance()} and \function{issubclass()} functions
that handle ExtensionClasses correctly.
\item Recent versions of the ZODB allow writing a class with
\method{__setattr__} , \method{__getattr__}, or \method{__delattr__} methods. (Older versions didn't support this at all.)
If you write such a \method{__setattr__} or \method{__delattr__} method,
its code has to set the dirty bit manually,
\end{itemize}
Let's look at each of these rules in detail.
\subsubsection{Modifying Mutable Objects}
The ZODB uses various Python hooks to catch attribute accesses, and
can trap most of the ways of modifying an object, but not all of them.
If you modify a \class{User} object by assigning to one of its
attributes, as in \code{userobj.first_name = 'Andrew'}, the ZODB will
mark the object as having been changed, and it'll be written out on
the following \method{commit()}.
The most common idiom that \emph{isn't} caught by the ZODB is
mutating a list or dictionary. If \class{User} objects have a
attribute named \code{friends} containing a list, calling
\code{userobj.friends.append(otherUser)} doesn't mark
\code{userobj} as modified; from the ZODB's point of
view, \code{userobj.friends} was only read, and its value, which
happened to be an ordinary Python list, was returned. The ZODB isn't
aware that the object returned was subsequently modified.
This is one of the few quirks you'll have to remember when using the
ZODB; if you modify a mutable attribute of an object in place, you
have to manually mark the object as having been modified by setting
its dirty bit to true. This is done by setting the
\member{_p_changed} attribute of the object to true:
\begin{verbatim}
userobj.friends.append(otherUser)
userobj._p_changed = 1
\end{verbatim}
An obsolete way of doing this that's still supported is calling the
\method{__changed__()} method instead, but setting \member{_p_changed}
is the preferred way.
You can hide the implementation detail of having to mark objects as
dirty by designing your class's API to not use direct attribute
access; instead, you can use the Java-style approach of accessor
methods for everything, and then set the dirty bit within the accessor
method. For example, you might forbid accessing the \code{friends}
attribute directly, and add a \method{get_friend_list()} accessor and
an \method{add_friend()} modifier method to the class. \method{add_friend()}
would then look like this:
\begin{verbatim}
def add_friend(self, friend):
self.friends.append(otherUser)
self._p_changed = 1
\end{verbatim}
Alternatively, you could use a ZODB-aware list or mapping type that
handles the dirty bit for you. The ZODB comes with a
\class{PersistentMapping} class, and I've contributed a
\class{PersistentList} class that's included in my ZODB distribution,
and may make it into a future upstream release of Zope.
% XXX It'd be nice to discuss what happens when an object is ``ghosted'' (e.g.
% you set an object's _p_changed = None). The __p_deactivate__ method should
% not be used (it's also obsolete).
\subsubsection{Some Special Methods Don't Work}
Don't bother defining certain special methods on
ExtensionClasses, because they won't work. Most notably, the
\method{__cmp__} method on an ExtensionClass will never be called.
Neither will the reversed versions of binary arithmetic operations,
such as \method{__radd__} and \method{__rsub__}.
This is a moderately annoying limitation. It means that the
\class{PersistentList} class can't implement comparisons with regular
sequence objects, and therefore statements such as
\verb|if perslist==[]| don't do what you expect; instead of performing the correct
comparison, they return some arbitrary fixed result, so the \code{if}
statement will always be true or always be false. There is no good
solution to this problem at the moment, so all you can do is design
class interfaces that don't need to overload
\method{__cmp__} or the \method{__r*__} methods.
This limitation is mostly Python's fault. As of Python 2.1, the most
recent version at this writing, the code which handles comparing two
Python objects contains a hard-wired check for objects that are class
instances, which means that \code{type(obj) == types.InstanceType}.
The code inside the Python interpreter looks like this:
\begin{verbatim}
/* Code to compare objects v and w */
if (PyInstance_Check(v) || PyInstance_Check(w))
return PyInstance_DoBinOp(v, w, "__cmp__", "__rcmp__", do_cmp);
/* Do usual Python comparison of v,w */
c = PyObject_Compare(v, w);
\end{verbatim}
While ExtensionClasses try to behave as much like regular Python
instances as possible, they are still not instances, and
\function{type()} doesn't return the \code{InstanceType} object, so
no attempt is ever made to call \method{__cmp__}. Perhaps Python 2.2
will repair this.
\subsubsection{Fixing \function{isinstance} and \function{issubclass}}
Python's built-in functions
\function{isinstance()} and \function{issubclass} don't
work on ExtensionClass instances, for much the same reason that
\method{__cmp__} is never called; in some bits of the Python core code,
branches are taken only if an object is of the \class{InstanceType}
type, and this can never be true for an ExtensionClass instance.
Python 2.1 tried to fix this, and changed these functions slightly in
an effort to make them work for ExtensionClasses; unfortunately, the
changes didn't work.
The solution is to use customized versions of these functions that
handle ExtensionClasses specially and fall back to the built-in
version otherwise. Here are the versions we've written at the MEMS Exchange:
\begin{verbatim}
# The built-in 'isinstance()' and 'issubclass()' won't work on
# ExtensionClasses, so you have to use the versions supplied here.
# (But those versions work fine on regular instances and classes too,
# so you should *always* use them.)
def issubclass (class1, class2):
"""A version of 'issubclass' that works with extension classes
as well as regular Python classes.
"""
# Both class objects are regular Python classes, so use the
# built-in 'issubclass()'.
if type(class1) is ClassType and type(class2) is ClassType:
return __builtin__.issubclass(class1, class2)
# Both so-called class objects have a '__bases__' attribute: ie.,
# they aren't regular Python classes, but they sure look like them.
# Assume they are extension classes and reimplement what the builtin
# 'issubclass()' does behind the scenes.
elif hasattr(class1, '__bases__') and hasattr(class2, '__bases__'):
# XXX it appears that "ec.__class__ is type(ec)" for an
# extension class 'ec': could we/should we use this as an
# additional check for extension classes?
# Breadth-first traversal of class1's superclass tree. Order
# doesn't matter because we're just looking for a "yes/no"
# answer from the tree; if we were trying to resolve a name,
# order would be important!
stack = [class1]
while stack:
if stack[0] is class2:
return 1
stack.extend(list(stack[0].__bases__))
del stack[0]
else:
return 0
# Not a regular class, not an extension class: blow up for consistency
# with builtin 'issubclass()"
else:
raise TypeError, "arguments must be class or ExtensionClass objects"
# issubclass ()
def isinstance (object, klass):
"""A version of 'isinstance' that works with extension classes
as well as regular Python classes."""
if type(klass) is TypeType:
return __builtin__.isinstance(object, klass)
elif hasattr(object, '__class__'):
return issubclass(object.__class__, klass)
else:
return 0
\end{verbatim}
I'd recommend putting these functions in a module that always gets
imported. The convention on my work project is to put them in
\file{mems/lib/base.py}, which contains various fundamental classes
and functions for our system, and access them like this:
\begin{verbatim}
from mems.lib import base
...
if base.isinstance(object, Class): ...
\end{verbatim}
Don't insert the modified functions into Python's
\module{__builtin__} module, or import just the
\function{isinstance()} and \function{issubclass} functions.
If you consistently use \function{base.isinstance()}, then forgetting
to import the \module{base} module will result in a
\exception{NameError} exception. In the
case of a forgotten import, calling the functions directly would use
Python's built-in versions, leading to subtle bugs that might not be
noticed for some time.
\subsubsection{\method{__getattr__}, \method{__delattr__}, and \method{__setattr__}}
Recent versions of ZODB allow writing persistent classes that have
\method{__getattr__}, \method{__delattr__}, or \method{__setattr__}
methods. The one minor complication is that the machinery for
automatically detecting changes to the object is disabled while the
\method{__getattr__}, \method{__delattr__}, or \method{__setattr__}
method is executing. This means that if the object is modified, the
object should be marked as dirty by setting the object's
\member{_p_changed} method to true.
\subsection{Writing Persistent Classes}
Now that we've looked at the basics of programming using the ZODB,
we'll turn to some more subtle tasks that are likely to come up for
anyone using the ZODB in a production system.
\subsubsection{Changing Instance Attributes}
Ideally, before making a class persistent you would get its interface
right the first time, so that no attributes would ever need to be
added, removed, or have their interpretation change over time. It's a
worthy goal, but also an impractical one unless you're gifted with
perfect knowledge of the future. Such unnatural foresight can't be
required of any person, so you therefore have to be prepared to handle
such structural changes gracefully. In object-oriented database
terminology, this is a schema update. The ZODB doesn't have an actual
schema specification, but you're changing the software's expectations
of the data contained by an object, so you're implicitly changing the
schema.
One way to handle such a change is to write a one-time conversion
program that will loop over every single object in the database and
update them to match the new schema. This can be easy if your network
of object references is quite structured, making it easy to find all
the instances of the class being modified. For example, if all
\class{User} objects can be found inside a single dictionary or
B-tree, then it would be a simple matter to loop over every
\class{User} instance with a \keyword{for} statement.
This is more difficult if your object graph is less structured; if
\class{User} objects can be found as attributes of any number of
different class instances, then there's no longer any easy way to find
them all, short of writing a generalized object traversal function
that would walk over every single object in a ZODB, checking each one
to see if it's an instance of \class{User}.
\footnote{XXX is there a convenience method for walking the object graph hiding
somewhere inside DC's code? Should there be a utility method for
doing this? Should I write one and include it in this section?}
Some OODBs support a feature called extents, which allow quickly
finding all the instances of a given class, no matter where they are
in the object graph; unfortunately the ZODB doesn't offer extents as a
feature.
XXX Rest of section not written yet: __getstate__/__setstate__
% Storages
% FileStorage
% BerkeleyStorage
% OracleStorage
\section{Storages}
This chapter will examine the different \class{Storage} subclasses
that are considered stable, discuss their varying characteristics, and
explain how to administer them.
\subsection{Using Multiple Storages}
XXX explain mounting substorages
\subsection{FileStorage}
\subsection{BerkeleyStorage}
\subsection{OracleStorage}
%Transactions and Versioning
% Committing and Aborting
% Subtransactions
% Undoing
% Versions
% Multithreaded ZODB Programs
\section{Transactions and Versioning}
%\subsection{Committing and Aborting}
% XXX There seems very little to say about commit/abort...
\subsection{Subtransactions}
Subtransactions can be created within a transaction. Each
subtransaction can be individually committed and aborted, but the
changes within a subtransaction are not truly committed until the
containing transaction is committed.
The primary purpose of subtransactions is to decrease the memory usage
of transactions that touch a very large number of objects. Consider a
transaction during which 200,000 objects are modified. All the
objects that are modified in a single transaction have to remain in
memory until the transaction is committed, because the ZODB can't
discard them from the object cache. This can potentially make the
memory usage quite large. With subtransactions, a commit can be be
performed at intervals, say, every 10,000 objects. Those 10,000
objects are then written to permanent storage and can be purged from
the cache to free more space.
To commit a subtransaction instead of a full transaction,
pass a true value to the \method{commit()}
or \method{abort()} method of the \class{Transaction} object.
\begin{verbatim}
# Commit a subtransaction
get_transaction().commit(1)
# Abort a subtransaction
get_transaction().abort(1)
\end{verbatim}
A new subtransaction is automatically started on committing or
aborting the previous subtransaction.
\subsection{Undoing Changes}
Some types of \class{Storage} support undoing a transaction even after
it's been committed. You can tell if this is the case by calling the
\method{supportsUndo()} method of the \class{DB} instance, which
returns true if the underlying storage supports undo. Alternatively
you can call the \method{supportsUndo()} method on the underlying
storage instance.
If a database supports undo, then the \method{undoLog(\var{start},
\var{end}\optional{, func})} method on the \class{DB} instance returns
the log of past transactions, returning transactions between the times
\var{start} and \var{end}, measured in seconds from the epoch.
If present, \var{func} is a function that acts as a filter on the
transactions to be returned; it's passed a dictionary representing
each transaction, and only transactions for which \var{func} returns
true will be included in the list of transactions returned to the
caller of \method{undoLog()}. The dictionary contains keys for
various properties of the transaction. The most important keys are
\samp{id}, for the transaction ID, and \samp{time}, for the time at
which the transaction was committed.
\begin{verbatim}
>>> print storage.undoLog(0, sys.maxint)
[{'description': '',
'id': 'AzpGEGqU/0QAAAAAAAAGMA',
'time': 981126744.98,
'user_name': ''},
{'description': '',
'id': 'AzpGC/hUOKoAAAAAAAAFDQ',
'time': 981126478.202,
'user_name': ''}
...
\end{verbatim}
To store a description and a user name on a commit, get the current
transaction and call the \method{note(\var{text})} method to store a
description, and the
\method{setUser(\var{user_name})} method to store the user name.
While \method{setUser()} overwrites the current user name and replaces
it with the new value, the \method{note()} method always adds the text
to the transaction's description, so it can be called several times to
log several different changes made in the course of a single
transaction.
\begin{verbatim}
get_transaction().setUser('amk')
get_transaction().note('Change ownership')
\end{verbatim}
To undo a transaction, call the \method{DB.undo(\var{id})} method,
passing it the ID of the transaction to undo. If the transaction
can't be undone, a \exception{ZODB.POSException.UndoError} exception
will be raised, with the message ``non-undoable
transaction''. Usually this will happen because later transactions
modified the objects affected by the transaction you're trying to
undo.
\subsection{Versions}
While many subtransactions can be contained within a single regular
transaction, it's also possible to contain many regular transactions
within a long-running transaction, called a version in ZODB
terminology. Inside a version, any number of transactions can be
created and committed or rolled back, but the changes within a version
are not made visible to other connections to the same ZODB.
Not all storages support versions, but you can test for versioning
ability by calling \method{supportsVersions()} method of the
\class{DB} instance, which returns true if the underlying storage
supports versioning.
A version can be selected when creating the \class{Connection}
instance using the \method{DB.open(\optional{\var{version}})} method.
The \var{version} argument must be a string that will be used as the
name of the version.
\begin{verbatim}
vers_conn = db.open(version='Working version')
\end{verbatim}
Transactions can then be committed and aborted using this versioned
connection. Other connections that don't specify a version, or
provide a different version name, will not see changes committed
within the version named \samp{Working~version}. To commit or abort a
version, which will either make the changes visible to all clients or
roll them back, call the \method{DB.commitVersion()} or
\method{DB.abortVersion()} methods.
XXX what are the source and dest arguments for?
The ZODB makes no attempt to reconcile changes between different
versions. Instead, the first version which modifies an object will
gain a lock on that object. Attempting to modify the object from a
different version or from an unversioned connection will cause a
\exception{ZODB.POSException.VersionLockError} to be raised:
\begin{verbatim}
from ZODB.POSException import VersionLockError
try:
get_transaction().commit()
except VersionLockError, (obj_id, version):
print ('Cannot commit; object %s '
'locked by version %s' % (obj_id, version))
\end{verbatim}
The exception provides the ID of the locked object, and the name of
the version having a lock on it.
\subsection{Multithreaded ZODB Programs}
ZODB databases can be accessed from multithreaded Python programs.
The \class{Storage} and \class{DB} instances can be shared among
several threads, as long as individual \class{Connection} instances
are created for each thread.
XXX I can't think of anything else to say about multithreaded ZODB
programs. Suggestions? An example program?
% ZEO
% Installing ZEO
% How ZEO works (ClientStorage)
% Configuring ZEO
\section{ZEO}
\label{zeo}
\subsection{How ZEO Works}
The ZODB, as I've described it so far, can only be used within a
single Python process (though perhaps with multiple threads). ZEO,
Zope Enterprise Objects, extends the ZODB machinery to provide access
to objects over a network. The name "Zope Enterprise Objects" is a
bit misleading; ZEO can be used to store Python objects and access
them in a distributed fashion without Zope ever entering the picture.
The combination of ZEO and ZODB is essentially a Python-specific
object database.
ZEO consists of about 1400 lines of Python code. The code is
relatively small because it contains only code for a TCP/IP server,
and for a new type of Storage, \class{ClientStorage}.
\class{ClientStorage} doesn't use disk files at all; it simply
makes remote procedure calls to the server, which then passes them on
a regular \class{Storage} class such as \class{FileStorage}. The
following diagram lays out the system:
XXX insert diagram here later
Any number of processes can create a \class{ClientStorage}
instance, and any number of threads in each process can be using that
instance. \class{ClientStorage} aggressively caches objects
locally, so in order to avoid using stale data, the ZEO server sends
an invalidate message to all the connected \class{ClientStorage}
instances on every write operation. The invalidate message contains
the object ID for each object that's been modified, letting the
\class{ClientStorage} instances delete the old data for the
given object from their caches.
This design decision has some consequences you should be aware of.
First, while ZEO isn't tied to Zope, it was first written for use with
Zope, which stores HTML, images, and program code in the database. As
a result, reads from the database are \emph{far} more frequent than
writes, and ZEO is therefore better suited for read-intensive
applications. If every \class{ClientStorage} is writing to the
database all the time, this will result in a storm of invalidate
messages being sent, and this might take up more processing time than
the actual database operations themselves.
On the other hand, for applications that have few writes in comparison
to the number of read accesses, this aggressive caching can be a major
win. Consider a Slashdot-like discussion forum that divides the load
among several Web servers. If news items and postings are represented
by objects and accessed through ZEO, then the most heavily accessed
objects -- the most recent or most popular postings -- will very
quickly wind up in the caches of the
\class{ClientStorage} instances on the front-end servers. The
back-end ZEO server will do relatively little work, only being called
upon to return the occasional older posting that's requested, and to
send the occasional invalidate message when a new posting is added.
The ZEO server isn't going to be contacted for every single request,
so its workload will remain manageable.
\subsection{Installing ZEO}
This section covers how to install the ZEO package, and how to
configure and run a ZEO Storage Server on a machine.
\subsubsection{Requirements}
To run a ZEO server, you'll need Python 1.5.2 or 2.0, and the ZODB
packages from \url{http://www.amk.ca/files/zodb/}
have to be installed.
\emph{Note for Python 1.5.2 users}: ZEO requires updated versions
of the \module{asyncore.py} and \module{asynchat.py} modules that are
included in 1.5.2's standard library. Current versions of the ZODB
distribution install private versions of these modules, so you
shouldn't need to grab updated versions yourself. (The symptom of
this problem is a traceback on attempting to run a ZEO client program:
the traceback is ``TypeError: too many arguments; expected 2, got 3''
around line 100 of \file{smac.py}.
\subsubsection{Installation}
Installing the ZEO package is easy. Just run \code{python setup.py
install}. This will install the ZEO/ package into your Python
installation, and copy various files into their proper locations:
\file{zeo.conf} will be put into \file{/usr/local/etc/}, a \file{zeo} startup
script will be put in \file{/etc/rc.d/init.d/}, and the \file{zeod}
daemon program will be placed in \file{/usr/local/bin}.
\subsection{Configuring and Running a ZEO Server}
Edit \code{/usr/local/etc/zeo.conf} appropriately for your desired
setup. This configuration file controls the port on which ZEO will
listen for connections, the user and group IDs under which the server
will be executed, and the location of the concrete \class{Storage}
object that will be made network-accessible.
\subsection{Testing the ZEO Installation}
Once a ZEO server is up and running, using it is just like using ZODB
with a more conventional disk-based storage; no new programming
details are introduced by using a remote server. The only difference
is that programs must create a \class{ClientStorage} instance instead
of a \class{FileStorage} instance. From that point onward, ZODB-based
code is happily unaware that objects are being retrieved from a ZEO
server, and not from the local disk.
As an example, and to test whether ZEO is working correctly, try
running the following lines of code, which will connect to the server,
add some bits of data to the root of the ZODB, and commits the
transaction:
\begin{verbatim}
from ZEO import ClientStorage
from ZODB import DB
# Change next line to connect to your ZEO server
addr = ('kronos.example.com', 1975)
storage = ClientStorage.ClientStorage(addr)
db = DB(storage)
conn = db.open()
root = conn.root()
# Store some things in the root
root['list'] = ['a', 'b', 1.0, 3]
root['dict'] = {'a':1, 'b':4}
# Commit the transaction
get_transaction().commit()
\end{verbatim}
If this code runs properly, then your ZEO server is working correctly.
\subsection{ZEO Programming Notes}
XXX The Connection.sync() method and its necessity (if it works at all!)
% That doesn't work. I tested it. sync() doesn't seem to get into
% the asyncore loop. One of us should probably look into adding an
% API for this when we have some free time. It would be a nice
% small project that would get into ZODB's guts.
\subsection{Sample Application: chatter.py}
For an example application, we'll build a little chat application.
What's interesting is that none of the application's code deals with
network programming at all; instead, an object will hold chat
messages, and be magically shared between all the clients through ZEO.
I won't present the complete script here; it's included in my ZODB
distribution, and you can download it from
\url{http://www.amk.ca/zodb/demos/}. Only the interesting portions of
the code will be covered here.
The basic data structure is the \class{ChatSession} object,
which provides an \method{add_message()} method that adds a
message, and a \method{new_messages()} method that returns a list
of new messages that have accumulated since the last call to
\method{new_messages()}. Internally, \class{ChatSession}
maintains a B-tree that uses the time as the key, and stores the
message as the corresponding value.
The constructor for \class{ChatSession} is pretty simple; it simply
creates an attribute containing a B-tree:
\begin{verbatim}
class ChatSession(Persistent):
def __init__(self, name):
self.name = name
# Internal attribute: _messages holds all the chat messages.
self._messages = BTree.BTree()
\end{verbatim}
\method{add_message()} has to add a message to the
\code{_messages} B-tree. A complication is that it's possible
that some other client is trying to add a message at the same time;
when this happens, the client that commits first wins, and the second
client will get a \exception{ConflictError} exception when it tries to
commit. For this application, \exception{ConflictError} isn't serious
but simply means that the operation has to be retried; other
applications might treat it as a fatal error. The code uses
\code{try...except...else} inside a \code{while} loop,
breaking out of the loop when the commit works without raising an
exception.
\begin{verbatim}
def add_message(self, message):
"""Add a message to the channel.
message -- text of the message to be added
"""
while 1:
try:
now = time.time()
self._messages[now] = message
get_transaction().commit()
except ConflictError:
# Conflict occurred; this process should pause and
# wait for a little bit, then try again.
time.sleep(.2)
pass
else:
# No ConflictError exception raised, so break
# out of the enclosing while loop.
break
# end while
\end{verbatim}
\method{new_messages()} introduces the use of \textit{volatile}
attributes. Attributes of a persistent object that begin with
\code{_v_} are considered volatile and are never stored in the
database. \method{new_messages()} needs to store the last time
the method was called, but if the time was stored as a regular
attribute, its value would be committed to the database and shared
with all the other clients. \method{new_messages()} would then
return the new messages accumulated since any other client called
\method{new_messages()}, which isn't what we want.
\begin{verbatim}
def new_messages(self):
"Return new messages."
# self._v_last_time is the time of the most recent message
# returned to the user of this class.
if not hasattr(self, '_v_last_time'):
self._v_last_time = 0
new = []
T = self._v_last_time
for T2, message in self._messages.items():
if T2 > T:
new.append(message)
self._v_last_time = T2
return new
\end{verbatim}
This application is interesting because it uses ZEO to easily share a
data structure; ZEO and ZODB are being used for their networking
ability, not primarily for their data storage ability. I can foresee
many interesting applications using ZEO in this way:
\begin{itemize}
\item With a Tkinter front-end, and a cleverer, more scalable data
structure, you could build a shared whiteboard using the same
technique.
\item A shared chessboard object would make writing a networked chess
game easy.
\item You could create a Python class containing a CD's title and
track information. To make a CD database, a read-only ZEO server
could be opened to the world, or an HTTP or XML-RPC interface could
be written on top of the ZODB.
\item A program like Quicken could use a ZODB on the local disk to
store its data. This avoids the need to write and maintain
specialized I/O code that reads in your objects and writes them out;
instead you can concentrate on the problem domain, writing objects
that represent cheques, stock portfolios, or whatever.
\end{itemize}
\documentclass{howto}
\title{ZODB/ZEO Programming Guide}
\release{0.03}
\date{\today}
\author{A.M.\ Kuchling}
\authoraddress{akuchlin@mems-exchange.org}
\begin{document}
\maketitle
\tableofcontents
\copyright{Copyright 2002 A.M. Kuchling.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the appendix entitled ``GNU
Free Documentation License''.}
\input{introduction}
\input{prog-zodb}
\input{zeo}
\input{transactions}
%\input{storages}
%\input{indexing}
%\input{admin}
\input{modules}
\appendix
\input links.tex
\input gfdl.tex
\end{document}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>About this document ...</title>
<META NAME="description" CONTENT="About this document ...">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node41.html">
<LINK REL="up" HREF="zodb.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node53.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node53.html">ADDENDUM: How to use</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000900000000000000000">
About this document ...</A>
</H1>
<strong>ZODB/ZEO Programming Guide</strong>,
February 8, 2002, Release 0.03
<p> This document was generated using the <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> translator.
</p>
<p> <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> is Copyright &copy;
1993, 1994, 1995, 1996, 1997, <a
href="http://cbl.leeds.ac.uk/nikos/personal.html">Nikos
Drakos</a>, Computer Based Learning Unit, University of
Leeds, and Copyright &copy; 1997, 1998, <a
href="http://www.maths.mq.edu.au/~ross/">Ross
Moore</a>, Mathematics Department, Macquarie University,
Sydney.
</p>
<p> The application of <a
href="http://saftsack.fs.uni-bayreuth.de/~latex2ht/">
<strong>LaTeX</strong>2<tt>HTML</tt></a> to the Python
documentation has been heavily tailored by Fred L. Drake,
Jr. Original navigation icons were contributed by Christopher
Petrilli.
</p>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node53.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node53.html">ADDENDUM: How to use</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Contents</title>
<META NAME="description" CONTENT="Contents">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node2.html">
<LINK REL="previous" HREF="zodb.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node2.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="zodb.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<BR>
<BR><H2><A NAME="SECTION000100000000000000000">
Contents</A>
</H2>
<!--Table of Contents-->
<UL>
<LI><A href="contents.html">Contents</a>
<LI><A href="node2.html">1 Introduction</a>
<UL>
<LI><A href="node3.html">1.1 What is the ZODB?</a>
<LI><A href="node4.html">1.2 OODBs vs. Relational DBs</a>
<LI><A href="node5.html">1.3 What is ZEO?</a>
<LI><A href="node6.html">1.4 About this guide</a>
<LI><A href="node7.html">1.5 Acknowledgements</a>
</ul>
<LI><A href="node8.html">2 ZODB Programming</a>
<UL>
<LI><A href="node9.html">2.1 Installing ZODB</a>
<LI><A href="node12.html">2.2 How ZODB Works</a>
<LI><A href="node13.html">2.3 Opening a ZODB</a>
<LI><A href="node14.html">2.4 Writing a Persistent Class</a>
<LI><A href="node15.html">2.5 Rules for Writing Persistent Classes</a>
<LI><A href="node20.html">2.6 Writing Persistent Classes</a>
</ul>
<LI><A href="zeo.html">3 ZEO</a>
<UL>
<LI><A href="node23.html">3.1 How ZEO Works</a>
<LI><A href="node24.html">3.2 Installing ZEO</a>
<LI><A href="node27.html">3.3 Configuring and Running a ZEO Server</a>
<LI><A href="node28.html">3.4 Testing the ZEO Installation</a>
<LI><A href="node29.html">3.5 ZEO Programming Notes</a>
<LI><A href="node30.html">3.6 Sample Application: chatter.py</a>
</ul>
<LI><A href="node31.html">4 Transactions and Versioning</a>
<UL>
<LI><A href="node32.html">4.1 Subtransactions</a>
<LI><A href="node33.html">4.2 Undoing Changes</a>
<LI><A href="node34.html">4.3 Versions</a>
<LI><A href="node35.html">4.4 Multithreaded ZODB Programs</a>
</ul>
<LI><A href="node36.html">5 Related Modules</a>
<UL>
<LI><A href="node37.html">5.1 <tt class="module">ZODB.PersistentMapping</tt></a>
<LI><A href="node38.html">5.2 <tt class="module">ZODB.PersistentList</tt></a>
<LI><A href="node39.html">5.3 B-tree Modules</a>
</ul>
<LI><A href="node40.html">A. Resources</a>
<LI><A href="node41.html">B. GNU Free Documentation License</a>
<UL>
<LI><A href="node42.html">Preamble</a>
<LI><A href="node43.html">B..1 Applicability and Definitions</a>
<LI><A href="node44.html">B..2 Verbatim Copying</a>
<LI><A href="node45.html">B..3 Copying in Quantity</a>
<LI><A href="node46.html">B..4 Modifications</a>
<LI><A href="node47.html">B..5 Combining Documents</a>
<LI><A href="node48.html">B..6 Collections of Documents</a>
<LI><A href="node49.html">B..7 Aggregation With Independent Works</a>
<LI><A href="node50.html">B..8 Translation</a>
<LI><A href="node51.html">B..9 Termination</a>
<LI><A href="node52.html">B..10 Future Revisions of This Licence</a>
<LI><A href="node53.html">ADDENDUM: How to use this License for your documents</a>
</ul>
<LI><A href="about.html">About this document ...</a>
</ul>
<!--End of Table of Contents-->
<P>
&#169;Copyright 2002 A.M. Kuchling.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
A copy of the license is included in the appendix entitled ``GNU
Free Documentation License''.
<P>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="zodb.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
\batchmode
\documentclass{howto}
\RequirePackage{ifthen}
\title{ZODB/ZEO Programming Guide}
\release{0.03}
\date{\today}
\author{A.M.\ Kuchling}\authoraddress{akuchlin@mems-exchange.org}
\usepackage[dvips]{color}
\pagecolor[gray]{.7}
\usepackage[latin1]{inputenc}
\makeatletter
\makeatletter
\count@=\the\catcode`\_ \catcode`\_=8
\newenvironment{tex2html_wrap}{}{}%
\catcode`\<=12\catcode`\_=\count@
\newcommand{\providedcommand}[1]{\expandafter\providecommand\csname #1\endcsname}%
\newcommand{\renewedcommand}[1]{\expandafter\providecommand\csname #1\endcsname{}%
\expandafter\renewcommand\csname #1\endcsname}%
\newcommand{\newedenvironment}[1]{\newenvironment{#1}{}{}\renewenvironment{#1}}%
\let\newedcommand\renewedcommand
\let\renewedenvironment\newedenvironment
\makeatother
\let\mathon=$
\let\mathoff=$
\ifx\AtBeginDocument\undefined \newcommand{\AtBeginDocument}[1]{}\fi
\newbox\sizebox
\setlength{\hoffset}{0pt}\setlength{\voffset}{0pt}
\addtolength{\textheight}{\footskip}\setlength{\footskip}{0pt}
\addtolength{\textheight}{\topmargin}\setlength{\topmargin}{0pt}
\addtolength{\textheight}{\headheight}\setlength{\headheight}{0pt}
\addtolength{\textheight}{\headsep}\setlength{\headsep}{0pt}
\setlength{\textwidth}{349pt}
\newwrite\lthtmlwrite
\makeatletter
\let\realnormalsize=\normalsize
\global\topskip=2sp
\def\preveqno{}\let\real@float=\@float \let\realend@float=\end@float
\def\@float{\let\@savefreelist\@freelist\real@float}
\def\liih@math{\ifmmode$\else\bad@math\fi}
\def\end@float{\realend@float\global\let\@freelist\@savefreelist}
\let\real@dbflt=\@dbflt \let\end@dblfloat=\end@float
\let\@largefloatcheck=\relax
\let\if@boxedmulticols=\iftrue
\def\@dbflt{\let\@savefreelist\@freelist\real@dbflt}
\def\adjustnormalsize{\def\normalsize{\mathsurround=0pt \realnormalsize
\parindent=0pt\abovedisplayskip=0pt\belowdisplayskip=0pt}%
\def\phantompar{\csname par\endcsname}\normalsize}%
\def\lthtmltypeout#1{{\let\protect\string \immediate\write\lthtmlwrite{#1}}}%
\newcommand\lthtmlhboxmathA{\adjustnormalsize\setbox\sizebox=\hbox\bgroup\kern.05em }%
\newcommand\lthtmlhboxmathB{\adjustnormalsize\setbox\sizebox=\hbox to\hsize\bgroup\hfill }%
\newcommand\lthtmlvboxmathA{\adjustnormalsize\setbox\sizebox=\vbox\bgroup %
\let\ifinner=\iffalse \let\)\liih@math }%
\newcommand\lthtmlboxmathZ{\@next\next\@currlist{}{\def\next{\voidb@x}}%
\expandafter\box\next\egroup}%
\newcommand\lthtmlmathtype[1]{\gdef\lthtmlmathenv{#1}}%
\newcommand\lthtmllogmath{\lthtmltypeout{l2hSize %
:\lthtmlmathenv:\the\ht\sizebox::\the\dp\sizebox::\the\wd\sizebox.\preveqno}}%
\newcommand\lthtmlfigureA[1]{\let\@savefreelist\@freelist
\lthtmlmathtype{#1}\lthtmlvboxmathA}%
\newcommand\lthtmlpictureA{\bgroup\catcode`\_=8 \lthtmlpictureB}%
\newcommand\lthtmlpictureB[1]{\lthtmlmathtype{#1}\egroup
\let\@savefreelist\@freelist \lthtmlhboxmathB}%
\newcommand\lthtmlpictureZ[1]{\hfill\lthtmlfigureZ}%
\newcommand\lthtmlfigureZ{\lthtmlboxmathZ\lthtmllogmath\copy\sizebox
\global\let\@freelist\@savefreelist}%
\newcommand\lthtmldisplayA{\bgroup\catcode`\_=8 \lthtmldisplayAi}%
\newcommand\lthtmldisplayAi[1]{\lthtmlmathtype{#1}\egroup\lthtmlvboxmathA}%
\newcommand\lthtmldisplayB[1]{\edef\preveqno{(\theequation)}%
\lthtmldisplayA{#1}\let\@eqnnum\relax}%
\newcommand\lthtmldisplayZ{\lthtmlboxmathZ\lthtmllogmath\lthtmlsetmath}%
\newcommand\lthtmlinlinemathA{\bgroup\catcode`\_=8 \lthtmlinlinemathB}
\newcommand\lthtmlinlinemathB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA
\vrule height1.5ex width0pt }%
\newcommand\lthtmlinlineA{\bgroup\catcode`\_=8 \lthtmlinlineB}%
\newcommand\lthtmlinlineB[1]{\lthtmlmathtype{#1}\egroup\lthtmlhboxmathA}%
\newcommand\lthtmlinlineZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
\expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetinline}
\newcommand\lthtmlinlinemathZ{\egroup\expandafter\ifdim\dp\sizebox>0pt %
\expandafter\centerinlinemath\fi\lthtmllogmath\lthtmlsetmath}
\newcommand\lthtmlindisplaymathZ{\egroup %
\centerinlinemath\lthtmllogmath\lthtmlsetmath}
\def\lthtmlsetinline{\hbox{\vrule width.1em \vtop{\vbox{%
\kern.1em\copy\sizebox}\ifdim\dp\sizebox>0pt\kern.1em\else\kern.3pt\fi
\ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\lthtmlsetmath{\hbox{\vrule width.1em\kern-.05em\vtop{\vbox{%
\kern.1em\kern0.8 pt\hbox{\hglue.17em\copy\sizebox\hglue0.8 pt}}\kern.3pt%
\ifdim\dp\sizebox>0pt\kern.1em\fi \kern0.8 pt%
\ifdim\hsize>\wd\sizebox \hrule depth1pt\fi}}}
\def\centerinlinemath{%
\dimen1=\ifdim\ht\sizebox<\dp\sizebox \dp\sizebox\else\ht\sizebox\fi
\advance\dimen1by.5pt \vrule width0pt height\dimen1 depth\dimen1
\dp\sizebox=\dimen1\ht\sizebox=\dimen1\relax}
\def\lthtmlcheckvsize{\ifdim\ht\sizebox<\vsize
\ifdim\wd\sizebox<\hsize\expandafter\hfill\fi \expandafter\vfill
\else\expandafter\vss\fi}%
\providecommand{\selectlanguage}[1]{}%
\makeatletter \tracingstats = 1
\begin{document}
\pagestyle{empty}\thispagestyle{empty}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hsize=\the\hsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength vsize=\the\vsize}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength hoffset=\the\hoffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength voffset=\the\voffset}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topmargin=\the\topmargin}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength topskip=\the\topskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headheight=\the\headheight}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength headsep=\the\headsep}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength parskip=\the\parskip}\lthtmltypeout{}%
\lthtmltypeout{latex2htmlLength oddsidemargin=\the\oddsidemargin}\lthtmltypeout{}%
\makeatletter
\if@twoside\lthtmltypeout{latex2htmlLength evensidemargin=\the\evensidemargin}%
\else\lthtmltypeout{latex2htmlLength evensidemargin=\the\oddsidemargin}\fi%
\lthtmltypeout{}%
\makeatother
\setcounter{page}{1}
\onecolumn
% !!! IMAGES START HERE !!!
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{subsubsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{subsubsection}
\stepcounter{subsubsection}
\stepcounter{subsubsection}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsubsection}
\stepcounter{subsubsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{section}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\appendix
\stepcounter{section}
\stepcounter{section}
{\newpage\clearpage
\lthtmlinlinemathA{tex2html_wrap_inline847}%
$\copyright$%
\lthtmlinlinemathZ
\lthtmlcheckvsize\clearpage}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\stepcounter{subsection}
\end{document}
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ZODB/ZEO Programming Guide</title>
<META NAME="description" CONTENT="ZODB/ZEO Programming Guide">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" href="contents.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><A href="contents.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Next:</b> <a class="sectref" href="contents.html">Contents</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<div class="titlepage">
<center>
<h1>ZODB/ZEO Programming Guide</h1>
<p><b><font size="+2">A.M. Kuchling</font></b></p>
<p>akuchlin@mems-exchange.org</p>
<p><strong>Release 0.03</strong><br>
<strong>February 8, 2002</strong></p>
<p>
</center>
</div>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"></a>
<UL>
<LI><A href="contents.html">Contents</a>
<LI><A href="node2.html">1 Introduction</a>
<UL>
<LI><A href="node3.html">1.1 What is the ZODB?</a>
<LI><A href="node4.html">1.2 OODBs vs. Relational DBs</a>
<LI><A href="node5.html">1.3 What is ZEO?</a>
<LI><A href="node6.html">1.4 About this guide</a>
<LI><A href="node7.html">1.5 Acknowledgements</a>
</ul>
<LI><A href="node8.html">2 ZODB Programming</a>
<UL>
<LI><A href="node9.html">2.1 Installing ZODB</a>
<UL>
<LI><A href="node10.html">2.1.1 Requirements</a>
<LI><A href="node11.html">2.1.2 Installing the Packages</a>
</ul>
<LI><A href="node12.html">2.2 How ZODB Works</a>
<LI><A href="node13.html">2.3 Opening a ZODB</a>
<LI><A href="node14.html">2.4 Writing a Persistent Class</a>
<LI><A href="node15.html">2.5 Rules for Writing Persistent Classes</a>
<UL>
<LI><A href="node16.html">2.5.1 Modifying Mutable Objects</a>
<LI><A href="node17.html">2.5.2 Some Special Methods Don't Work</a>
<LI><A href="node18.html">2.5.3 Fixing <tt class="function">isinstance</tt> and <tt class="function">issubclass</tt></a>
<LI><A href="node19.html">2.5.4 <tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, and <tt class="method">__setattr__</tt></a>
</ul>
<LI><A href="node20.html">2.6 Writing Persistent Classes</a>
<UL>
<LI><A href="node21.html">2.6.1 Changing Instance Attributes</a>
</ul>
</ul>
<LI><A href="zeo.html">3 ZEO</a>
<UL>
<LI><A href="node23.html">3.1 How ZEO Works</a>
<LI><A href="node24.html">3.2 Installing ZEO</a>
<UL>
<LI><A href="node25.html">3.2.1 Requirements</a>
<LI><A href="node26.html">3.2.2 Installation</a>
</ul>
<LI><A href="node27.html">3.3 Configuring and Running a ZEO Server</a>
<LI><A href="node28.html">3.4 Testing the ZEO Installation</a>
<LI><A href="node29.html">3.5 ZEO Programming Notes</a>
<LI><A href="node30.html">3.6 Sample Application: chatter.py</a>
</ul>
<LI><A href="node31.html">4 Transactions and Versioning</a>
<UL>
<LI><A href="node32.html">4.1 Subtransactions</a>
<LI><A href="node33.html">4.2 Undoing Changes</a>
<LI><A href="node34.html">4.3 Versions</a>
<LI><A href="node35.html">4.4 Multithreaded ZODB Programs</a>
</ul>
<LI><A href="node36.html">5 Related Modules</a>
<UL>
<LI><A href="node37.html">5.1 <tt class="module">ZODB.PersistentMapping</tt></a>
<LI><A href="node38.html">5.2 <tt class="module">ZODB.PersistentList</tt></a>
<LI><A href="node39.html">5.3 B-tree Modules</a>
</ul>
<LI><A href="node40.html">A. Resources</a>
<LI><A href="node41.html">B. GNU Free Documentation License</a>
<UL>
<LI><A href="node42.html">Preamble</a>
<LI><A href="node43.html">B..1 Applicability and Definitions</a>
<LI><A href="node44.html">B..2 Verbatim Copying</a>
<LI><A href="node45.html">B..3 Copying in Quantity</a>
<LI><A href="node46.html">B..4 Modifications</a>
<LI><A href="node47.html">B..5 Combining Documents</a>
<LI><A href="node48.html">B..6 Collections of Documents</a>
<LI><A href="node49.html">B..7 Aggregation With Independent Works</a>
<LI><A href="node50.html">B..8 Translation</a>
<LI><A href="node51.html">B..9 Termination</a>
<LI><A href="node52.html">B..10 Future Revisions of This Licence</a>
<LI><A href="node53.html">ADDENDUM: How to use this License for your documents</a>
</ul>
<LI><A href="about.html">About this document ...</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><A href="contents.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Next:</b> <a class="sectref" href="contents.html">Contents</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.1.1 Requirements</title>
<META NAME="description" CONTENT="2.1.1 Requirements">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node11.html">
<LINK REL="previous" HREF="node9.html">
<LINK REL="up" HREF="node9.html">
<LINK REL="next" HREF="node11.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node9.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node11.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node11.html">2.1.2 Installing the Packages</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000311000000000000000">
2.1.1 Requirements</A>
</H3>
<P>
You'll need Python, of course; version 1.5.2 works with some fixes,
and it also works with Python 2.0, which is what I primarily use.
<P>
The code is packaged using Distutils, the new distribution tools for
Python introduced in Python 2.0. If you're using 1.5.2, first you'll
have to get the latest Distutils release from the Distutils SIG page
at <a class="url" href="http://www.python.org/sigs/distutils-sig/download.html">http://www.python.org/sigs/distutils-sig/download.html</a> and
install it. This is simply a matter of untarring or unzipping the
release package, and then running <code>python setup.py install</code>.
<P>
If you're using 1.5.2 and have installed previous versions of the
Distutils, be sure to get the very latest version, since developing
the ZODB distribution turned up some bugs along the way. If you
encounter problems compiling <span class="file">ZODB/TimeStamp.c</span> or your compiler reports
an error like ``Can't create build/temp.linux2/ExtensionClass.o: No
such file or directory'', you need an updated version. Old versions of
Distutils have two bugs which affect the setup scripts. First, for a
long time the <code>define_macros</code> keyword in setup.py files didn't work due
to a Distutils bug, so I hacked TimeStamp.c in earlier releases. The
Distutils have since been fixed, and the hack became unnecessary, so I
removed it. Second, the code that creates directories tries to be
smart and caches them to save time by not trying to create a directory
twice, but this code was broken in old versions.
<P>
You'll need a C compiler to build the packages, because there are
various C extension modules. At the moment no one is making Windows
binaries available, so you'll need a Windows development environment to use the
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node9.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node11.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node11.html">2.1.2 Installing the Packages</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.1.2 Installing the Packages</title>
<META NAME="description" CONTENT="2.1.2 Installing the Packages">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node10.html">
<LINK REL="up" HREF="node9.html">
<LINK REL="next" HREF="node12.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node10.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node12.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node10.html">2.1.1 Requirements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node12.html">2.2 How ZODB Works</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000312000000000000000">
2.1.2 Installing the Packages</A>
</H3>
<P>
Download the ZODB tarball containing all the packages for both ZODB
and ZEO from <a class="url" href="http://www.amk.ca/files/zodb/">http://www.amk.ca/files/zodb/</a>.
<P>
To build the packages, you must go into the individual directories and
build and install them one by one. They should be built and installed
in this order:
<P>
<OL>
<LI><code>zodb-basic</code>
</LI>
<LI>ExtensionClass
</LI>
<LI>ZODB
</LI>
<LI><code>BTree</code> and <code>BTrees</code>
</LI>
<LI>ZEO
</LI>
</OL>
<P>
In particular, you must install ExtensionClass before building the
ZODB package; otherwise, the compilation in the ZODB package will die
complaining that it can't find ExtensionClass.h. You can manually
hack the #include path to make it work without installing
ExtensionClass first, but that's a bit hackish.
<P>
If you encounter any problems, please let me know at
<span class="email">akuchlin@mems-exchange.org</span>.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node10.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node12.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node10.html">2.1.1 Requirements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node12.html">2.2 How ZODB Works</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.2 How ZODB Works</title>
<META NAME="description" CONTENT="2.2 How ZODB Works">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node13.html">
<LINK REL="previous" HREF="node9.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node13.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node11.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node13.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node11.html">2.1.2 Installing the Packages</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node13.html">2.3 Opening a ZODB</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000320000000000000000">
2.2 How ZODB Works</A>
</H2>
<P>
The ZODB is conceptually simple. Python classes subclass a
<tt class="class">Persistent</tt> class to become ZODB-aware.
Instances of persistent objects are brought in from a permanent
storage medium, such as a disk file, when the program needs them, and
remain cached in RAM. The ZODB traps modifications to objects, so
that when a statement such as <code>obj.size = 1</code> is executed, the
modified object is marked as ``dirty''. On request, any dirty objects
are written out to permanent storage; this is called committing a
transaction. Transactions can also be aborted or rolled back, which
results in any changes being discarded, dirty objects reverting to
their initial state before the transaction began.
<P>
The term ``transaction'' has a specific technical meaning in computer
science. It's extremely important that the contents of a database
don't get corrupted by software or hardware crashes, and most database
software offers protection against such corruption by supporting four
useful properties, Atomicity, Consistency, Isolation, and Durability.
In computer science jargon these four terms are collectively dubbed
the ACID properties, forming an acronym from their names. The
definitions of the ACID properties are:
<P>
<DL COMPACT>
<DT>Atomicity</DT>
<DD>means that any changes to data made during a transaction
are all-or-nothing. Either all the changes are applied, or none of
them are. If a program makes a bunch of modifications and then
crashes, the database won't be partially modified, potentially leaving
the data in an inconsistent state; instead all the changes will be
forgotten. That's bad, but it's better than having a
partially-applied modification put the database into an inconsistent
state.
<P>
</DD>
<DT>Consistency</DT>
<DD>means that the data cannot be placed into a
logically invalid state; sanity checks can be written and enforced.
Usually this is done by defining a database schema, and requiring the
data always matches the schema. For example, this might enforce that
the <code>order_number</code> attribute is always an integer, and not a
string, tuple, or other object.
<P>
</DD>
<DT>Isolation</DT>
<DD>means that two programs or threads running in two
different transactions cannot see each other's changes until they
commit their transactions.
<P>
</DD>
<DT>Durability</DT>
<DD>means that once a transaction has been committed,
a subsequent crash will not cause any data to be lost or corrupted.
<P>
</DD>
</DL>
<P>
The ZODB provides 3 of the ACID properties. Only Consistency is not
supported; the ZODB has no notion of a database schema, and therefore
has no way of enforcing consistency with a schema.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node11.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node13.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node11.html">2.1.2 Installing the Packages</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node13.html">2.3 Opening a ZODB</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.3 Opening a ZODB</title>
<META NAME="description" CONTENT="2.3 Opening a ZODB">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node14.html">
<LINK REL="previous" HREF="node12.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node14.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node12.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node14.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node12.html">2.2 How ZODB Works</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node14.html">2.4 Writing a Persistent</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000330000000000000000">
2.3 Opening a ZODB</A>
</H2>
<P>
There are 3 main interfaces supplied by the ZODB:
<tt class="class">Storage</tt>, <tt class="class">DB</tt>, and <tt class="class">Connection</tt> classes. The
<tt class="class">DB</tt> and <tt class="class">Connection</tt> interfaces both have single
implementations, but there are several different classes that
implement the <tt class="class">Storage</tt> interface.
<P>
<UL>
<LI><tt class="class">Storage</tt> classes are the lowest layer, and handle
storing and retrieving objects from some form of long-term storage.
A few different types of Storage have been written, such as
<tt class="class">FileStorage</tt>, which uses regular disk files, and
<tt class="class">BerkeleyStorage</tt>, which uses Sleepycat Software's BerkeleyDB
database. You could write a new Storage that stored objects in a
relational database or Metakit file, for example, if that would
better suit your application. Two example storages,
<tt class="class">DemoStorage</tt> and <tt class="class">MappingStorage</tt>, are available to use
as models if you want to write a new Storage.
<P>
</LI>
<LI>The <tt class="class">DB</tt> class sits on top of a storage, and mediates the
interaction between several connections. One <tt class="class">DB</tt> instance is
created per process.
<P>
</LI>
<LI>Finally, the <tt class="class">Connection</tt> class caches objects, and moves
them into and out of object storage. A multi-threaded program can
open a separate <tt class="class">Connection</tt> instance for each thread.
Different threads can then modify objects and commit their
modifications independently.
<P>
</LI>
</UL>
<P>
Preparing to use a ZODB requires 3 steps: you have to open the
<tt class="class">Storage</tt>, then create a <tt class="class">DB</tt> instance that uses the <tt class="class">Storage</tt>, and then get
a <tt class="class">Connection</tt> from the <tt class="class">DB instance</tt>. All this is only a few lines of
code:
<P>
<dl><dd><pre class="verbatim">
from ZODB import FileStorage, DB
storage = FileStorage.FileStorage('/tmp/test-filestorage.fs')
db = DB(storage)
conn = db.open()
</pre></dl>
<P>
Note that you can use a completely different data storage mechanism by
changing the first line that opens a <tt class="class">Storage</tt>; the above example uses a
<tt class="class">FileStorage</tt>. In section&nbsp;<A href="zeo.html#zeo">3</A>, ``How ZEO Works'',
you'll see how ZEO uses this flexibility to good effect.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node12.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node14.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node12.html">2.2 How ZODB Works</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node14.html">2.4 Writing a Persistent</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.4 Writing a Persistent Class</title>
<META NAME="description" CONTENT="2.4 Writing a Persistent Class">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node15.html">
<LINK REL="previous" HREF="node13.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node15.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node13.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node13.html">2.3 Opening a ZODB</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000340000000000000000">
2.4 Writing a Persistent Class</A>
</H2>
<P>
Making a Python class persistent is quite simple; it simply needs to
subclass from the <tt class="class">Persistent</tt> class, as shown in this example:
<P>
<dl><dd><pre class="verbatim">
import ZODB
from Persistence import Persistent
class User(Persistent):
pass
</pre></dl>
<P>
The apparently unnecessary <code>import ZODB</code> statement is
needed for the following <code>from...import</code> statement to work
correctly, since the ZODB code does some magical tricks with
importing.
<P>
For simplicity, in the examples the <tt class="class">User</tt> class will
simply be used as a holder for a bunch of attributes. Normally the
class would define various methods that add functionality, but that
has no impact on the ZODB's treatment of the class.
<P>
The ZODB uses persistence by reachability; starting from a set of root
objects, all the attributes of those objects are made persistent,
whether they're simple Python data types or class instances. There's
no method to explicitly store objects in a ZODB database; simply
assign them as an attribute of an object, or store them in a mapping,
that's already in the database. This chain of containment must
eventually reach back to the root object of the database.
<P>
As an example, we'll create a simple database of users that allows
retrieving a <tt class="class">User</tt> object given the user's ID. First, we
retrieve the primary root object of the ZODB using the <tt class="method">root()</tt>
method of the <tt class="class">Connection</tt> instance. The root object behaves
like a Python dictionary, so you can just add a new key/value pair for
your application's root object. We'll insert a <tt class="class">BTree</tt> object
that will contain all the <tt class="class">User</tt> objects. (The
<tt class="class">BTree</tt> module is also included as part of Zope.)
<P>
<dl><dd><pre class="verbatim">
dbroot = conn.root()
# Ensure that a 'userdb' key is present
# in the root
if not dbroot.has_key('userdb'):
import BTree
dbroot['userdb'] = BTree.BTree()
userdb = dbroot['userdb']
</pre></dl>
<P>
Inserting a new user is simple: create the <tt class="class">User</tt> object, fill
it with data, insert it into the <tt class="class">BTree</tt> instance, and commit
this transaction.
<P>
<dl><dd><pre class="verbatim"># Create new User instance
newuser = User()
# Add whatever attributes you want to track
newuser.id = 'amk'
newuser.first_name = 'Andrew' ; newuser.last_name = 'Kuchling'
...
# Add object to the BTree, keyed on the ID
userdb[newuser.id] = newuser
# Commit the change
get_transaction().commit()
</pre></dl>
<P>
When you import the ZODB package, it adds a new function,
<tt class="function">get_transaction()</tt>, to Python's collection of built-in
functions. <tt class="function">get_transaction()</tt> returns a <tt class="class">Transaction</tt>
object, which has two important methods: <tt class="method">commit()</tt> and
<tt class="method">abort()</tt>. <tt class="method">commit()</tt> writes any modified objects
to disk, making the changes permanent, while <tt class="method">abort()</tt> rolls
back any changes that have been made, restoring the original state of
the objects. If you're familiar with database transactional
semantics, this is all what you'd expect.
<P>
Because the integration with Python is so complete, it's a lot like
having transactional semantics for your program's variables, and you
can experiment with transactions at the Python interpreter's prompt:
<P>
<dl><dd><pre class="verbatim">&gt;&gt;&gt; newuser
&lt;User instance at 81b1f40&gt;
&gt;&gt;&gt; newuser.first_name # Print initial value
'Andrew'
&gt;&gt;&gt; newuser.first_name = 'Bob' # Change first name
&gt;&gt;&gt; newuser.first_name # Verify the change
'Bob'
&gt;&gt;&gt; get_transaction().abort() # Abort transaction
&gt;&gt;&gt; newuser.first_name # The value has changed back
'Andrew'
</pre></dl>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node13.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node13.html">2.3 Opening a ZODB</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.5 Rules for Writing Persistent Classes</title>
<META NAME="description" CONTENT="2.5 Rules for Writing Persistent Classes">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node20.html">
<LINK REL="previous" HREF="node14.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node16.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node14.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node16.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node14.html">2.4 Writing a Persistent</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node16.html">2.5.1 Modifying Mutable Objects</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000350000000000000000">
2.5 Rules for Writing Persistent Classes</A>
</H2>
<P>
Practically all persistent languages impose some restrictions on
programming style, warning against constructs they can't handle or
adding subtle semantic changes, and the ZODB is no exception.
Happily, the ZODB's restrictions are fairly simple to understand, and
in practice it isn't too painful to work around them.
<P>
The summary of rules is as follows:
<P>
<UL>
<LI>If you modify a mutable object that's the value of an object's
attribute, the ZODB can't catch that, and won't mark the object as
dirty.
The solution is to either set the dirty bit yourself when you modify
mutable objects, or use a wrapper for Python's lists and dictionaries
(<tt class="class">PersistentList</tt>,
<tt class="class">PersistentMapping</tt>)
that will set the dirty bit properly.
<P>
</LI>
<LI>Certain of Python's special methods don't work when they're
defined on ExtensionClasses. The most important ones are the
<tt class="method">__cmp__</tt> method, and the reversed versions of binary
arithmetic operations: <tt class="method">__radd__</tt>, <tt class="method">__rsub__</tt>, and so
forth.
<P>
</LI>
<LI>Python's built-in <tt class="function">isinstance()</tt> and <tt class="function">issubclass()</tt>
functions don't work properly on ExtensionClasses. Solution: use
custom <tt class="function">isinstance()</tt> and <tt class="function">issubclass()</tt> functions
that handle ExtensionClasses correctly.
<P>
</LI>
<LI>Recent versions of the ZODB allow writing a class with
<tt class="method">__setattr__</tt> , <tt class="method">__getattr__</tt>, or <tt class="method">__delattr__</tt> methods. (Older versions didn't support this at all.)
If you write such a <tt class="method">__setattr__</tt> or <tt class="method">__delattr__</tt> method,
its code has to set the dirty bit manually,
<P>
</LI>
</UL>
<P>
Let's look at each of these rules in detail.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node16.html">2.5.1 Modifying Mutable Objects</a>
<LI><A href="node17.html">2.5.2 Some Special Methods Don't Work</a>
<LI><A href="node18.html">2.5.3 Fixing <tt class="function">isinstance</tt> and <tt class="function">issubclass</tt></a>
<LI><A href="node19.html">2.5.4 <tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, and <tt class="method">__setattr__</tt></a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node14.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node16.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node14.html">2.4 Writing a Persistent</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node16.html">2.5.1 Modifying Mutable Objects</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.5.1 Modifying Mutable Objects</title>
<META NAME="description" CONTENT="2.5.1 Modifying Mutable Objects">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node17.html">
<LINK REL="previous" HREF="node15.html">
<LINK REL="up" HREF="node15.html">
<LINK REL="next" HREF="node17.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node15.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node17.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node17.html">2.5.2 Some Special Methods</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000351000000000000000">
2.5.1 Modifying Mutable Objects</A>
</H3>
<P>
The ZODB uses various Python hooks to catch attribute accesses, and
can trap most of the ways of modifying an object, but not all of them.
If you modify a <tt class="class">User</tt> object by assigning to one of its
attributes, as in <code>userobj.first_name = 'Andrew'</code>, the ZODB will
mark the object as having been changed, and it'll be written out on
the following <tt class="method">commit()</tt>.
<P>
The most common idiom that <i>isn't</i> caught by the ZODB is
mutating a list or dictionary. If <tt class="class">User</tt> objects have a
attribute named <code>friends</code> containing a list, calling
<code>userobj.friends.append(otherUser)</code> doesn't mark
<code>userobj</code> as modified; from the ZODB's point of
view, <code>userobj.friends</code> was only read, and its value, which
happened to be an ordinary Python list, was returned. The ZODB isn't
aware that the object returned was subsequently modified.
<P>
This is one of the few quirks you'll have to remember when using the
ZODB; if you modify a mutable attribute of an object in place, you
have to manually mark the object as having been modified by setting
its dirty bit to true. This is done by setting the
<tt class="member">_p_changed</tt> attribute of the object to true:
<P>
<dl><dd><pre class="verbatim">
userobj.friends.append(otherUser)
userobj._p_changed = 1
</pre></dl>
<P>
An obsolete way of doing this that's still supported is calling the
<tt class="method">__changed__()</tt> method instead, but setting <tt class="member">_p_changed</tt>
is the preferred way.
<P>
You can hide the implementation detail of having to mark objects as
dirty by designing your class's API to not use direct attribute
access; instead, you can use the Java-style approach of accessor
methods for everything, and then set the dirty bit within the accessor
method. For example, you might forbid accessing the <code>friends</code>
attribute directly, and add a <tt class="method">get_friend_list()</tt> accessor and
an <tt class="method">add_friend()</tt> modifier method to the class. <tt class="method">add_friend()</tt>
would then look like this:
<P>
<dl><dd><pre class="verbatim">
def add_friend(self, friend):
self.friends.append(otherUser)
self._p_changed = 1
</pre></dl>
<P>
Alternatively, you could use a ZODB-aware list or mapping type that
handles the dirty bit for you. The ZODB comes with a
<tt class="class">PersistentMapping</tt> class, and I've contributed a
<tt class="class">PersistentList</tt> class that's included in my ZODB distribution,
and may make it into a future upstream release of Zope.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node15.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node17.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node17.html">2.5.2 Some Special Methods</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.5.2 Some Special Methods Don't Work</title>
<META NAME="description" CONTENT="2.5.2 Some Special Methods Don't Work">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node18.html">
<LINK REL="previous" HREF="node16.html">
<LINK REL="up" HREF="node15.html">
<LINK REL="next" HREF="node18.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node16.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node18.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node16.html">2.5.1 Modifying Mutable Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node18.html">2.5.3 Fixing isinstance and</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000352000000000000000">
2.5.2 Some Special Methods Don't Work</A>
</H3>
<P>
Don't bother defining certain special methods on
ExtensionClasses, because they won't work. Most notably, the
<tt class="method">__cmp__</tt> method on an ExtensionClass will never be called.
Neither will the reversed versions of binary arithmetic operations,
such as <tt class="method">__radd__</tt> and <tt class="method">__rsub__</tt>.
<P>
This is a moderately annoying limitation. It means that the
<tt class="class">PersistentList</tt> class can't implement comparisons with regular
sequence objects, and therefore statements such as
<code>if perslist==[]</code> don't do what you expect; instead of performing the correct
comparison, they return some arbitrary fixed result, so the <code>if</code>
statement will always be true or always be false. There is no good
solution to this problem at the moment, so all you can do is design
class interfaces that don't need to overload
<tt class="method">__cmp__</tt> or the <tt class="method">__r*__</tt> methods.
<P>
This limitation is mostly Python's fault. As of Python 2.1, the most
recent version at this writing, the code which handles comparing two
Python objects contains a hard-wired check for objects that are class
instances, which means that <code>type(obj) == types.InstanceType</code>.
The code inside the Python interpreter looks like this:
<P>
<dl><dd><pre class="verbatim">
/* Code to compare objects v and w */
if (PyInstance_Check(v) || PyInstance_Check(w))
return PyInstance_DoBinOp(v, w, "__cmp__", "__rcmp__", do_cmp);
/* Do usual Python comparison of v,w */
c = PyObject_Compare(v, w);
</pre></dl>
<P>
While ExtensionClasses try to behave as much like regular Python
instances as possible, they are still not instances, and
<tt class="function">type()</tt> doesn't return the <code>InstanceType</code> object, so
no attempt is ever made to call <tt class="method">__cmp__</tt>. Perhaps Python 2.2
will repair this.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node16.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node18.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node16.html">2.5.1 Modifying Mutable Objects</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node18.html">2.5.3 Fixing isinstance and</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.5.3 Fixing isinstance and issubclass</title>
<META NAME="description" CONTENT="2.5.3 Fixing isinstance and issubclass">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node19.html">
<LINK REL="previous" HREF="node17.html">
<LINK REL="up" HREF="node15.html">
<LINK REL="next" HREF="node19.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node17.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node19.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node17.html">2.5.2 Some Special Methods</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node19.html">2.5.4 __getattr__, __delattr__, and</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000353000000000000000">
2.5.3 Fixing <tt class="function">isinstance</tt> and <tt class="function">issubclass</tt></A>
</H3>
<P>
Python's built-in functions
<tt class="function">isinstance()</tt> and <tt class="function">issubclass</tt> don't
work on ExtensionClass instances, for much the same reason that
<tt class="method">__cmp__</tt> is never called; in some bits of the Python core code,
branches are taken only if an object is of the <tt class="class">InstanceType</tt>
type, and this can never be true for an ExtensionClass instance.
Python 2.1 tried to fix this, and changed these functions slightly in
an effort to make them work for ExtensionClasses; unfortunately, the
changes didn't work.
<P>
The solution is to use customized versions of these functions that
handle ExtensionClasses specially and fall back to the built-in
version otherwise. Here are the versions we've written at the MEMS Exchange:
<P>
<dl><dd><pre class="verbatim">
# The built-in 'isinstance()' and 'issubclass()' won't work on
# ExtensionClasses, so you have to use the versions supplied here.
# (But those versions work fine on regular instances and classes too,
# so you should *always* use them.)
def issubclass (class1, class2):
"""A version of 'issubclass' that works with extension classes
as well as regular Python classes.
"""
# Both class objects are regular Python classes, so use the
# built-in 'issubclass()'.
if type(class1) is ClassType and type(class2) is ClassType:
return __builtin__.issubclass(class1, class2)
# Both so-called class objects have a '__bases__' attribute: ie.,
# they aren't regular Python classes, but they sure look like them.
# Assume they are extension classes and reimplement what the builtin
# 'issubclass()' does behind the scenes.
elif hasattr(class1, '__bases__') and hasattr(class2, '__bases__'):
# XXX it appears that "ec.__class__ is type(ec)" for an
# extension class 'ec': could we/should we use this as an
# additional check for extension classes?
# Breadth-first traversal of class1's superclass tree. Order
# doesn't matter because we're just looking for a "yes/no"
# answer from the tree; if we were trying to resolve a name,
# order would be important!
stack = [class1]
while stack:
if stack[0] is class2:
return 1
stack.extend(list(stack[0].__bases__))
del stack[0]
else:
return 0
# Not a regular class, not an extension class: blow up for consistency
# with builtin 'issubclass()"
else:
raise TypeError, "arguments must be class or ExtensionClass objects"
# issubclass ()
def isinstance (object, klass):
"""A version of 'isinstance' that works with extension classes
as well as regular Python classes."""
if type(klass) is TypeType:
return __builtin__.isinstance(object, klass)
elif hasattr(object, '__class__'):
return issubclass(object.__class__, klass)
else:
return 0
</pre></dl>
<P>
I'd recommend putting these functions in a module that always gets
imported. The convention on my work project is to put them in
<span class="file">mems/lib/base.py</span>, which contains various fundamental classes
and functions for our system, and access them like this:
<P>
<dl><dd><pre class="verbatim">
from mems.lib import base
...
if base.isinstance(object, Class): ...
</pre></dl>
<P>
Don't insert the modified functions into Python's
<tt class="module">__builtin__</tt> module, or import just the
<tt class="function">isinstance()</tt> and <tt class="function">issubclass</tt> functions.
If you consistently use <tt class="function">base.isinstance()</tt>, then forgetting
to import the <tt class="module">base</tt> module will result in a
<tt class="exception">NameError</tt> exception. In the
case of a forgotten import, calling the functions directly would use
Python's built-in versions, leading to subtle bugs that might not be
noticed for some time.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node17.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node19.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node17.html">2.5.2 Some Special Methods</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node19.html">2.5.4 __getattr__, __delattr__, and</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.5.4 __getattr__, __delattr__, and __setattr__</title>
<META NAME="description" CONTENT="2.5.4 __getattr__, __delattr__, and __setattr__">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node18.html">
<LINK REL="up" HREF="node15.html">
<LINK REL="next" HREF="node20.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node18.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node20.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node18.html">2.5.3 Fixing isinstance and</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000354000000000000000">
2.5.4 <tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, and <tt class="method">__setattr__</tt></A>
</H3>
<P>
Recent versions of ZODB allow writing persistent classes that have
<tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, or <tt class="method">__setattr__</tt>
methods. The one minor complication is that the machinery for
automatically detecting changes to the object is disabled while the
<tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, or <tt class="method">__setattr__</tt>
method is executing. This means that if the object is modified, the
object should be marked as dirty by setting the object's
<tt class="member">_p_changed</tt> method to true.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node18.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node15.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node20.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node18.html">2.5.3 Fixing isinstance and</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node15.html">2.5 Rules for Writing</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1 Introduction</title>
<META NAME="description" CONTENT="1 Introduction">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node8.html">
<LINK REL="previous" href="contents.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node3.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="contents.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node3.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="contents.html">Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node3.html">1.1 What is the</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000200000000000000000">
1 Introduction</A>
</H1>
<P>
This guide explains how to write Python programs that use the Z Object
Database (ZODB) and Zope Enterprise Objects (ZEO). The latest version
of the guide is always available at
<a class="url" href="http://www.amk.ca/zodb/guide/">http://www.amk.ca/zodb/guide/</a>.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node3.html">1.1 What is the ZODB?</a>
<LI><A href="node4.html">1.2 OODBs vs. Relational DBs</a>
<LI><A href="node5.html">1.3 What is ZEO?</a>
<LI><A href="node6.html">1.4 About this guide</a>
<LI><A href="node7.html">1.5 Acknowledgements</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="contents.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node3.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="contents.html">Contents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node3.html">1.1 What is the</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.6 Writing Persistent Classes</title>
<META NAME="description" CONTENT="2.6 Writing Persistent Classes">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node15.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node21.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node19.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node21.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node19.html">2.5.4 __getattr__, __delattr__, and</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node21.html">2.6.1 Changing Instance Attributes</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000360000000000000000">
2.6 Writing Persistent Classes</A>
</H2>
<P>
Now that we've looked at the basics of programming using the ZODB,
we'll turn to some more subtle tasks that are likely to come up for
anyone using the ZODB in a production system.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node21.html">2.6.1 Changing Instance Attributes</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node19.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node21.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node19.html">2.5.4 __getattr__, __delattr__, and</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node21.html">2.6.1 Changing Instance Attributes</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.6.1 Changing Instance Attributes</title>
<META NAME="description" CONTENT="2.6.1 Changing Instance Attributes">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node20.html">
<LINK REL="up" HREF="node20.html">
<LINK REL="next" href="zeo.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node20.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node20.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<b class="navlabel">Next:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000361000000000000000">
2.6.1 Changing Instance Attributes</A>
</H3>
<P>
Ideally, before making a class persistent you would get its interface
right the first time, so that no attributes would ever need to be
added, removed, or have their interpretation change over time. It's a
worthy goal, but also an impractical one unless you're gifted with
perfect knowledge of the future. Such unnatural foresight can't be
required of any person, so you therefore have to be prepared to handle
such structural changes gracefully. In object-oriented database
terminology, this is a schema update. The ZODB doesn't have an actual
schema specification, but you're changing the software's expectations
of the data contained by an object, so you're implicitly changing the
schema.
<P>
One way to handle such a change is to write a one-time conversion
program that will loop over every single object in the database and
update them to match the new schema. This can be easy if your network
of object references is quite structured, making it easy to find all
the instances of the class being modified. For example, if all
<tt class="class">User</tt> objects can be found inside a single dictionary or
B-tree, then it would be a simple matter to loop over every
<tt class="class">User</tt> instance with a <tt class="keyword">for</tt> statement.
This is more difficult if your object graph is less structured; if
<tt class="class">User</tt> objects can be found as attributes of any number of
different class instances, then there's no longer any easy way to find
them all, short of writing a generalized object traversal function
that would walk over every single object in a ZODB, checking each one
to see if it's an instance of <tt class="class">User</tt>.
<A NAME="tex2html1"
HREF="#foot287"><SUP>1</SUP></A>Some OODBs support a feature called extents, which allow quickly
finding all the instances of a given class, no matter where they are
in the object graph; unfortunately the ZODB doesn't offer extents as a
feature.
<P>
XXX Rest of section not written yet: __getstate__/__setstate__
<P>
<BR><HR><H4>Footnotes</H4>
<DL>
<DT><A NAME="foot287">...User.
</A><A NAME="foot287"
HREF="node21.html#tex2html1"><SUP>1</SUP></A>
<DD>XXX is there a convenience method for walking the object graph hiding
somewhere inside DC's code? Should there be a utility method for
doing this? Should I write one and include it in this section?
</DL>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node20.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node20.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node20.html">2.6 Writing Persistent Classes</A>
<b class="navlabel">Next:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.1 How ZEO Works</title>
<META NAME="description" CONTENT="3.1 How ZEO Works">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node24.html">
<LINK REL="previous" href="zeo.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node24.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="zeo.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000410000000000000000">
3.1 How ZEO Works</A>
</H2>
<P>
The ZODB, as I've described it so far, can only be used within a
single Python process (though perhaps with multiple threads). ZEO,
Zope Enterprise Objects, extends the ZODB machinery to provide access
to objects over a network. The name "Zope Enterprise Objects" is a
bit misleading; ZEO can be used to store Python objects and access
them in a distributed fashion without Zope ever entering the picture.
The combination of ZEO and ZODB is essentially a Python-specific
object database.
<P>
ZEO consists of about 1400 lines of Python code. The code is
relatively small because it contains only code for a TCP/IP server,
and for a new type of Storage, <tt class="class">ClientStorage</tt>.
<tt class="class">ClientStorage</tt> doesn't use disk files at all; it simply
makes remote procedure calls to the server, which then passes them on
a regular <tt class="class">Storage</tt> class such as <tt class="class">FileStorage</tt>. The
following diagram lays out the system:
<P>
XXX insert diagram here later
<P>
Any number of processes can create a <tt class="class">ClientStorage</tt>
instance, and any number of threads in each process can be using that
instance. <tt class="class">ClientStorage</tt> aggressively caches objects
locally, so in order to avoid using stale data, the ZEO server sends
an invalidate message to all the connected <tt class="class">ClientStorage</tt>
instances on every write operation. The invalidate message contains
the object ID for each object that's been modified, letting the
<tt class="class">ClientStorage</tt> instances delete the old data for the
given object from their caches.
<P>
This design decision has some consequences you should be aware of.
First, while ZEO isn't tied to Zope, it was first written for use with
Zope, which stores HTML, images, and program code in the database. As
a result, reads from the database are <i>far</i> more frequent than
writes, and ZEO is therefore better suited for read-intensive
applications. If every <tt class="class">ClientStorage</tt> is writing to the
database all the time, this will result in a storm of invalidate
messages being sent, and this might take up more processing time than
the actual database operations themselves.
<P>
On the other hand, for applications that have few writes in comparison
to the number of read accesses, this aggressive caching can be a major
win. Consider a Slashdot-like discussion forum that divides the load
among several Web servers. If news items and postings are represented
by objects and accessed through ZEO, then the most heavily accessed
objects - the most recent or most popular postings - will very
quickly wind up in the caches of the
<tt class="class">ClientStorage</tt> instances on the front-end servers. The
back-end ZEO server will do relatively little work, only being called
upon to return the occasional older posting that's requested, and to
send the occasional invalidate message when a new posting is added.
The ZEO server isn't going to be contacted for every single request,
so its workload will remain manageable.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A href="zeo.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.2 Installing ZEO</title>
<META NAME="description" CONTENT="3.2 Installing ZEO">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node27.html">
<LINK REL="previous" HREF="node23.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node25.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node23.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node25.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node23.html">3.1 How ZEO Works</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node25.html">3.2.1 Requirements</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000420000000000000000">
3.2 Installing ZEO</A>
</H2>
<P>
This section covers how to install the ZEO package, and how to
configure and run a ZEO Storage Server on a machine.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node25.html">3.2.1 Requirements</a>
<LI><A href="node26.html">3.2.2 Installation</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node23.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node25.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node23.html">3.1 How ZEO Works</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node25.html">3.2.1 Requirements</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.2.1 Requirements</title>
<META NAME="description" CONTENT="3.2.1 Requirements">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node26.html">
<LINK REL="previous" HREF="node24.html">
<LINK REL="up" HREF="node24.html">
<LINK REL="next" HREF="node26.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node24.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node26.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node26.html">3.2.2 Installation</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000421000000000000000">
3.2.1 Requirements</A>
</H3>
<P>
To run a ZEO server, you'll need Python 1.5.2 or 2.0, and the ZODB
packages from <a class="url" href="http://www.amk.ca/files/zodb/">http://www.amk.ca/files/zodb/</a>have to be installed.
<P>
<i>Note for Python 1.5.2 users</i>: ZEO requires updated versions
of the <tt class="module">asyncore.py</tt> and <tt class="module">asynchat.py</tt> modules that are
included in 1.5.2's standard library. Current versions of the ZODB
distribution install private versions of these modules, so you
shouldn't need to grab updated versions yourself. (The symptom of
this problem is a traceback on attempting to run a ZEO client program:
the traceback is ``TypeError: too many arguments; expected 2, got 3''
around line 100 of <span class="file">smac.py</span>.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node24.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node26.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node26.html">3.2.2 Installation</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.2.2 Installation</title>
<META NAME="description" CONTENT="3.2.2 Installation">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node25.html">
<LINK REL="up" HREF="node24.html">
<LINK REL="next" HREF="node27.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node25.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node27.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node25.html">3.2.1 Requirements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node27.html">3.3 Configuring and Running</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H3><A NAME="SECTION000422000000000000000">
3.2.2 Installation</A>
</H3>
<P>
Installing the ZEO package is easy. Just run <code>python setup.py
install</code>. This will install the ZEO/ package into your Python
installation, and copy various files into their proper locations:
<span class="file">zeo.conf</span> will be put into <span class="file">/usr/local/etc/</span>, a <span class="file">zeo</span> startup
script will be put in <span class="file">/etc/rc.d/init.d/</span>, and the <span class="file">zeod</span>
daemon program will be placed in <span class="file">/usr/local/bin</span>.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node25.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node24.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node27.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node25.html">3.2.1 Requirements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node24.html">3.2 Installing ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node27.html">3.3 Configuring and Running</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.3 Configuring and Running a ZEO Server</title>
<META NAME="description" CONTENT="3.3 Configuring and Running a ZEO Server">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node28.html">
<LINK REL="previous" HREF="node24.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node28.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node26.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node28.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node26.html">3.2.2 Installation</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node28.html">3.4 Testing the ZEO</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000430000000000000000">
3.3 Configuring and Running a ZEO Server</A>
</H2>
<P>
Edit <code>/usr/local/etc/zeo.conf</code> appropriately for your desired
setup. This configuration file controls the port on which ZEO will
listen for connections, the user and group IDs under which the server
will be executed, and the location of the concrete <tt class="class">Storage</tt>
object that will be made network-accessible.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node26.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node28.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node26.html">3.2.2 Installation</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node28.html">3.4 Testing the ZEO</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.4 Testing the ZEO Installation</title>
<META NAME="description" CONTENT="3.4 Testing the ZEO Installation">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node29.html">
<LINK REL="previous" HREF="node27.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node29.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node27.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node29.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node27.html">3.3 Configuring and Running</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node29.html">3.5 ZEO Programming Notes</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000440000000000000000">
3.4 Testing the ZEO Installation</A>
</H2>
<P>
Once a ZEO server is up and running, using it is just like using ZODB
with a more conventional disk-based storage; no new programming
details are introduced by using a remote server. The only difference
is that programs must create a <tt class="class">ClientStorage</tt> instance instead
of a <tt class="class">FileStorage</tt> instance. From that point onward, ZODB-based
code is happily unaware that objects are being retrieved from a ZEO
server, and not from the local disk.
<P>
As an example, and to test whether ZEO is working correctly, try
running the following lines of code, which will connect to the server,
add some bits of data to the root of the ZODB, and commits the
transaction:
<P>
<dl><dd><pre class="verbatim">
from ZEO import ClientStorage
from ZODB import DB
# Change next line to connect to your ZEO server
addr = ('kronos.example.com', 1975)
storage = ClientStorage.ClientStorage(addr)
db = DB(storage)
conn = db.open()
root = conn.root()
# Store some things in the root
root['list'] = ['a', 'b', 1.0, 3]
root['dict'] = {'a':1, 'b':4}
# Commit the transaction
get_transaction().commit()
</pre></dl>
<P>
If this code runs properly, then your ZEO server is working correctly.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node27.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node29.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node27.html">3.3 Configuring and Running</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node29.html">3.5 ZEO Programming Notes</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.5 ZEO Programming Notes</title>
<META NAME="description" CONTENT="3.5 ZEO Programming Notes">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node30.html">
<LINK REL="previous" HREF="node28.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node30.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node28.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node30.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node28.html">3.4 Testing the ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node30.html">3.6 Sample Application: chatter.py</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000450000000000000000">
3.5 ZEO Programming Notes</A>
</H2>
<P>
XXX The Connection.sync() method and its necessity (if it works at all!)
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node28.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node30.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node28.html">3.4 Testing the ZEO</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node30.html">3.6 Sample Application: chatter.py</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1.1 What is the ZODB?</title>
<META NAME="description" CONTENT="1.1 What is the ZODB?">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node4.html">
<LINK REL="previous" HREF="node2.html">
<LINK REL="up" HREF="node2.html">
<LINK REL="next" HREF="node4.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node2.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node4.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node4.html">1.2 OODBs vs. Relational</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000210000000000000000">
1.1 What is the ZODB?</A>
</H2>
<P>
The ZODB is a persistence system for Python objects. Persistent
programming languages provide facilities that automatically write
objects to disk and read them in again when they're required by a
running program. By installing the ZODB, you add such facilities to
Python.
<P>
It's certainly possible to build your own system for making Python
objects persistent. The usual starting points are the <tt class="module">pickle</tt>
module, for converting objects into a string representation, and
various database modules, such as the <tt class="module">gdbm</tt> or <tt class="module">bsddb</tt>
modules, that provide ways to write strings to disk and read them
back. It's straightforward to combine the <tt class="module">pickle</tt> module and
a database module to store and retrieve objects, and in fact the
<tt class="module">shelve</tt> module, included in Python's standard library, does
this.
<P>
The downside is that the programmer has to explicitly manage objects,
reading an object when it's needed and writing it out to disk when the
object is no longer required. The ZODB manages objects for you,
keeping them in a cache and writing them out if they haven't been
accessed in a while.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node2.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node4.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node4.html">1.2 OODBs vs. Relational</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3.6 Sample Application: chatter.py</title>
<META NAME="description" CONTENT="3.6 Sample Application: chatter.py">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node29.html">
<LINK REL="up" href="zeo.html">
<LINK REL="next" HREF="node31.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node29.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node29.html">3.5 ZEO Programming Notes</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000460000000000000000">
3.6 Sample Application: chatter.py</A>
</H2>
<P>
For an example application, we'll build a little chat application.
What's interesting is that none of the application's code deals with
network programming at all; instead, an object will hold chat
messages, and be magically shared between all the clients through ZEO.
I won't present the complete script here; it's included in my ZODB
distribution, and you can download it from
<a class="url" href="http://www.amk.ca/zodb/demos/">http://www.amk.ca/zodb/demos/</a>. Only the interesting portions of
the code will be covered here.
<P>
The basic data structure is the <tt class="class">ChatSession</tt> object,
which provides an <tt class="method">add_message()</tt> method that adds a
message, and a <tt class="method">new_messages()</tt> method that returns a list
of new messages that have accumulated since the last call to
<tt class="method">new_messages()</tt>. Internally, <tt class="class">ChatSession</tt>
maintains a B-tree that uses the time as the key, and stores the
message as the corresponding value.
<P>
The constructor for <tt class="class">ChatSession</tt> is pretty simple; it simply
creates an attribute containing a B-tree:
<P>
<dl><dd><pre class="verbatim">
class ChatSession(Persistent):
def __init__(self, name):
self.name = name
# Internal attribute: _messages holds all the chat messages.
self._messages = BTree.BTree()
</pre></dl>
<P>
<tt class="method">add_message()</tt> has to add a message to the
<code>_messages</code> B-tree. A complication is that it's possible
that some other client is trying to add a message at the same time;
when this happens, the client that commits first wins, and the second
client will get a <tt class="exception">ConflictError</tt> exception when it tries to
commit. For this application, <tt class="exception">ConflictError</tt> isn't serious
but simply means that the operation has to be retried; other
applications might treat it as a fatal error. The code uses
<code>try...except...else</code> inside a <code>while</code> loop,
breaking out of the loop when the commit works without raising an
exception.
<P>
<dl><dd><pre class="verbatim">
def add_message(self, message):
"""Add a message to the channel.
message -- text of the message to be added
"""
while 1:
try:
now = time.time()
self._messages[now] = message
get_transaction().commit()
except ConflictError:
# Conflict occurred; this process should pause and
# wait for a little bit, then try again.
time.sleep(.2)
pass
else:
# No ConflictError exception raised, so break
# out of the enclosing while loop.
break
# end while
</pre></dl>
<P>
<tt class="method">new_messages()</tt> introduces the use of <i>volatile</i>
attributes. Attributes of a persistent object that begin with
<code>_v_</code> are considered volatile and are never stored in the
database. <tt class="method">new_messages()</tt> needs to store the last time
the method was called, but if the time was stored as a regular
attribute, its value would be committed to the database and shared
with all the other clients. <tt class="method">new_messages()</tt> would then
return the new messages accumulated since any other client called
<tt class="method">new_messages()</tt>, which isn't what we want.
<P>
<dl><dd><pre class="verbatim">
def new_messages(self):
"Return new messages."
# self._v_last_time is the time of the most recent message
# returned to the user of this class.
if not hasattr(self, '_v_last_time'):
self._v_last_time = 0
new = []
T = self._v_last_time
for T2, message in self._messages.items():
if T2 &gt; T:
new.append(message)
self._v_last_time = T2
return new
</pre></dl>
<P>
This application is interesting because it uses ZEO to easily share a
data structure; ZEO and ZODB are being used for their networking
ability, not primarily for their data storage ability. I can foresee
many interesting applications using ZEO in this way:
<P>
<UL>
<LI>With a Tkinter front-end, and a cleverer, more scalable data
structure, you could build a shared whiteboard using the same
technique.
<P>
</LI>
<LI>A shared chessboard object would make writing a networked chess
game easy.
<P>
</LI>
<LI>You could create a Python class containing a CD's title and
track information. To make a CD database, a read-only ZEO server
could be opened to the world, or an HTTP or XML-RPC interface could
be written on top of the ZODB.
<P>
</LI>
<LI>A program like Quicken could use a ZODB on the local disk to
store its data. This avoids the need to write and maintain
specialized I/O code that reads in your objects and writes them out;
instead you can concentrate on the problem domain, writing objects
that represent cheques, stock portfolios, or whatever.
<P>
</LI>
</UL>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node29.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A href="zeo.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node29.html">3.5 ZEO Programming Notes</A>
<b class="navlabel">Up:</b> <a class="sectref" href="zeo.html">3 ZEO</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4 Transactions and Versioning</title>
<META NAME="description" CONTENT="4 Transactions and Versioning">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node36.html">
<LINK REL="previous" href="zeo.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node32.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node30.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node32.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node30.html">3.6 Sample Application: chatter.py</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node32.html">4.1 Subtransactions</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000500000000000000000">
4 Transactions and Versioning</A>
</H1>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node32.html">4.1 Subtransactions</a>
<LI><A href="node33.html">4.2 Undoing Changes</a>
<LI><A href="node34.html">4.3 Versions</a>
<LI><A href="node35.html">4.4 Multithreaded ZODB Programs</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node30.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node32.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node30.html">3.6 Sample Application: chatter.py</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node32.html">4.1 Subtransactions</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.1 Subtransactions</title>
<META NAME="description" CONTENT="4.1 Subtransactions">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node33.html">
<LINK REL="previous" HREF="node31.html">
<LINK REL="up" HREF="node31.html">
<LINK REL="next" HREF="node33.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node31.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node33.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node33.html">4.2 Undoing Changes</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000510000000000000000">
4.1 Subtransactions</A>
</H2>
<P>
Subtransactions can be created within a transaction. Each
subtransaction can be individually committed and aborted, but the
changes within a subtransaction are not truly committed until the
containing transaction is committed.
<P>
The primary purpose of subtransactions is to decrease the memory usage
of transactions that touch a very large number of objects. Consider a
transaction during which 200,000 objects are modified. All the
objects that are modified in a single transaction have to remain in
memory until the transaction is committed, because the ZODB can't
discard them from the object cache. This can potentially make the
memory usage quite large. With subtransactions, a commit can be be
performed at intervals, say, every 10,000 objects. Those 10,000
objects are then written to permanent storage and can be purged from
the cache to free more space.
<P>
To commit a subtransaction instead of a full transaction,
pass a true value to the <tt class="method">commit()</tt>
or <tt class="method">abort()</tt> method of the <tt class="class">Transaction</tt> object.
<P>
<dl><dd><pre class="verbatim">
# Commit a subtransaction
get_transaction().commit(1)
# Abort a subtransaction
get_transaction().abort(1)
</pre></dl>
<P>
A new subtransaction is automatically started on committing or
aborting the previous subtransaction.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node31.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node33.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node33.html">4.2 Undoing Changes</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.2 Undoing Changes</title>
<META NAME="description" CONTENT="4.2 Undoing Changes">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node34.html">
<LINK REL="previous" HREF="node32.html">
<LINK REL="up" HREF="node31.html">
<LINK REL="next" HREF="node34.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node32.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node34.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node32.html">4.1 Subtransactions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node34.html">4.3 Versions</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000520000000000000000">
4.2 Undoing Changes</A>
</H2>
<P>
Some types of <tt class="class">Storage</tt> support undoing a transaction even after
it's been committed. You can tell if this is the case by calling the
<tt class="method">supportsUndo()</tt> method of the <tt class="class">DB</tt> instance, which
returns true if the underlying storage supports undo. Alternatively
you can call the <tt class="method">supportsUndo()</tt> method on the underlying
storage instance.
<P>
If a database supports undo, then the <tt class="method">undoLog(<var>start</var>,
<var>end</var><big>[</big>, func<big>]</big>)</tt> method on the <tt class="class">DB</tt> instance returns
the log of past transactions, returning transactions between the times
<var>start</var> and <var>end</var>, measured in seconds from the epoch.
If present, <var>func</var> is a function that acts as a filter on the
transactions to be returned; it's passed a dictionary representing
each transaction, and only transactions for which <var>func</var> returns
true will be included in the list of transactions returned to the
caller of <tt class="method">undoLog()</tt>. The dictionary contains keys for
various properties of the transaction. The most important keys are
"<tt class="samp">id</tt>", for the transaction ID, and "<tt class="samp">time</tt>", for the time at
which the transaction was committed.
<P>
<dl><dd><pre class="verbatim">
&gt;&gt;&gt; print storage.undoLog(0, sys.maxint)
[{'description': '',
'id': 'AzpGEGqU/0QAAAAAAAAGMA',
'time': 981126744.98,
'user_name': ''},
{'description': '',
'id': 'AzpGC/hUOKoAAAAAAAAFDQ',
'time': 981126478.202,
'user_name': ''}
...
</pre></dl>
<P>
To store a description and a user name on a commit, get the current
transaction and call the <tt class="method">note(<var>text</var>)</tt> method to store a
description, and the
<tt class="method">setUser(<var>user_name</var>)</tt> method to store the user name.
While <tt class="method">setUser()</tt> overwrites the current user name and replaces
it with the new value, the <tt class="method">note()</tt> method always adds the text
to the transaction's description, so it can be called several times to
log several different changes made in the course of a single
transaction.
<P>
<dl><dd><pre class="verbatim">
get_transaction().setUser('amk')
get_transaction().note('Change ownership')
</pre></dl>
<P>
To undo a transaction, call the <tt class="method">DB.undo(<var>id</var>)</tt> method,
passing it the ID of the transaction to undo. If the transaction
can't be undone, a <tt class="exception">ZODB.POSException.UndoError</tt> exception
will be raised, with the message ``non-undoable
transaction''. Usually this will happen because later transactions
modified the objects affected by the transaction you're trying to
undo.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node32.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node34.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node32.html">4.1 Subtransactions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node34.html">4.3 Versions</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.3 Versions</title>
<META NAME="description" CONTENT="4.3 Versions">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node35.html">
<LINK REL="previous" HREF="node33.html">
<LINK REL="up" HREF="node31.html">
<LINK REL="next" HREF="node35.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node33.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node35.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node33.html">4.2 Undoing Changes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node35.html">4.4 Multithreaded ZODB Programs</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000530000000000000000">
4.3 Versions</A>
</H2>
<P>
While many subtransactions can be contained within a single regular
transaction, it's also possible to contain many regular transactions
within a long-running transaction, called a version in ZODB
terminology. Inside a version, any number of transactions can be
created and committed or rolled back, but the changes within a version
are not made visible to other connections to the same ZODB.
<P>
Not all storages support versions, but you can test for versioning
ability by calling <tt class="method">supportsVersions()</tt> method of the
<tt class="class">DB</tt> instance, which returns true if the underlying storage
supports versioning.
<P>
A version can be selected when creating the <tt class="class">Connection</tt>
instance using the <tt class="method">DB.open(<big>[</big><var>version</var><big>]</big>)</tt> method.
The <var>version</var> argument must be a string that will be used as the
name of the version.
<P>
<dl><dd><pre class="verbatim">
vers_conn = db.open(version='Working version')
</pre></dl>
<P>
Transactions can then be committed and aborted using this versioned
connection. Other connections that don't specify a version, or
provide a different version name, will not see changes committed
within the version named "<tt class="samp">Working&nbsp;version</tt>". To commit or abort a
version, which will either make the changes visible to all clients or
roll them back, call the <tt class="method">DB.commitVersion()</tt> or
<tt class="method">DB.abortVersion()</tt> methods.
XXX what are the source and dest arguments for?
<P>
The ZODB makes no attempt to reconcile changes between different
versions. Instead, the first version which modifies an object will
gain a lock on that object. Attempting to modify the object from a
different version or from an unversioned connection will cause a
<tt class="exception">ZODB.POSException.VersionLockError</tt> to be raised:
<P>
<dl><dd><pre class="verbatim">
from ZODB.POSException import VersionLockError
try:
get_transaction().commit()
except VersionLockError, (obj_id, version):
print ('Cannot commit; object %s '
'locked by version %s' % (obj_id, version))
</pre></dl>
<P>
The exception provides the ID of the locked object, and the name of
the version having a lock on it.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node33.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node35.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node33.html">4.2 Undoing Changes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node35.html">4.4 Multithreaded ZODB Programs</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>4.4 Multithreaded ZODB Programs</title>
<META NAME="description" CONTENT="4.4 Multithreaded ZODB Programs">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node34.html">
<LINK REL="up" HREF="node31.html">
<LINK REL="next" HREF="node36.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node34.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node34.html">4.3 Versions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000540000000000000000">
4.4 Multithreaded ZODB Programs</A>
</H2>
<P>
ZODB databases can be accessed from multithreaded Python programs.
The <tt class="class">Storage</tt> and <tt class="class">DB</tt> instances can be shared among
several threads, as long as individual <tt class="class">Connection</tt> instances
are created for each thread.
<P>
XXX I can't think of anything else to say about multithreaded ZODB
programs. Suggestions? An example program?
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node34.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node31.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node34.html">4.3 Versions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node31.html">4 Transactions and Versioning</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>5 Related Modules</title>
<META NAME="description" CONTENT="5 Related Modules">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node40.html">
<LINK REL="previous" HREF="node31.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node37.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node35.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node37.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node35.html">4.4 Multithreaded ZODB Programs</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node37.html">5.1 ZODB.PersistentMapping</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000600000000000000000">
5 Related Modules</A>
</H1>
<P>
The ZODB package includes a number of related modules that provide
useful data types such as BTrees or full-text indexes.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node37.html">5.1 <tt class="module">ZODB.PersistentMapping</tt></a>
<LI><A href="node38.html">5.2 <tt class="module">ZODB.PersistentList</tt></a>
<LI><A href="node39.html">5.3 B-tree Modules</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node35.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node37.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node35.html">4.4 Multithreaded ZODB Programs</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node37.html">5.1 ZODB.PersistentMapping</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>5.1 ZODB.PersistentMapping</title>
<META NAME="description" CONTENT="5.1 ZODB.PersistentMapping">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node38.html">
<LINK REL="previous" HREF="node36.html">
<LINK REL="up" HREF="node36.html">
<LINK REL="next" HREF="node38.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node36.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node38.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node38.html">5.2 ZODB.PersistentList</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000610000000000000000">
5.1 <tt class="module">ZODB.PersistentMapping</tt></A>
</H2>
<P>
The <tt class="class">PersistentMapping</tt> class is a wrapper for mapping objects
that will set the dirty bit when the mapping is modified by setting or
deleting a key.
<P>
<dl><dt><b><a name="l2h-1"><tt class="function">PersistentMapping</tt></a></b>(<var>container = {}</var>)
<dd>
Create a <tt class="class">PersistentMapping</tt> object that wraps the
mapping object <var>container</var>. If you don't specify a
value for <var>container</var>, a regular Python dictionary is used.
</dl>
<P>
<tt class="class">PersistentMapping</tt> objects support all the same methods as
Python dictionaries do.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node36.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node38.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node38.html">5.2 ZODB.PersistentList</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>5.2 ZODB.PersistentList</title>
<META NAME="description" CONTENT="5.2 ZODB.PersistentList">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node39.html">
<LINK REL="previous" HREF="node37.html">
<LINK REL="up" HREF="node36.html">
<LINK REL="next" HREF="node39.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node37.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node39.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node37.html">5.1 ZODB.PersistentMapping</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node39.html">5.3 B-tree Modules</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000620000000000000000">
5.2 <tt class="module">ZODB.PersistentList</tt></A>
</H2>
<P>
The <tt class="class">PersistentList</tt> class is a wrapper for mutable sequence objects,
much as <tt class="class">PersistentMapping</tt> is a wrapper for mappings.
<P>
<dl><dt><b><a name="l2h-2"><tt class="function">PersistentList</tt></a></b>(<var>initlist = []</var>)
<dd>
Create a <tt class="class">PersistentList</tt> object that wraps the
mutable sequence object <var>initlist</var>. If you don't specify a
value for <var>initlist</var>, a regular Python list is used.
</dl>
<P>
<tt class="class">PersistentList</tt> objects support all the same methods as
Python lists do.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node37.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node39.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node37.html">5.1 ZODB.PersistentMapping</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node39.html">5.3 B-tree Modules</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>5.3 B-tree Modules</title>
<META NAME="description" CONTENT="5.3 B-tree Modules">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node38.html">
<LINK REL="up" HREF="node36.html">
<LINK REL="next" HREF="node40.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node38.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node40.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node38.html">5.2 ZODB.PersistentList</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node40.html">A. Resources</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000630000000000000000">
5.3 B-tree Modules</A>
</H2>
<P>
When programming with the ZODB, Python dictionaries aren't always what
you need. The most important case is where you want to store a very
large mapping. When a Python dictionary is accessed in a ZODB, the
whole dictionary has to be unpickled and brought into memory. If
you're storing something very large, such as a 100,000-entry user
database, unpickling such a large object will be slow. B-trees are a
balanced tree data structure that behave like a mapping but distribute
keys throughout a number of tree nodes. Nodes are then only unpickled
and brought into memory as they're accessed, so the entire tree
doesn't have to occupy memory (unless you really are touching every
single key).
<P>
There are four different BTree modules provided. One of them, the
<tt class="module">BTree</tt> module, provides the most general data type; the keys
and values in the B-tree can be any Python object. Some specialized B-tree
modules require that the keys, and perhaps even the values, to be of a
certain type, and provide faster performance because of this limitation.
<P>
<DL COMPACT>
<DT> <tt class="module">IOBTree</tt> </DT>
<DD>requires the keys to be integers.
The module name reminds you of this; the <tt class="module">IOBTree</tt> module
maps Integers to Objects.
<P>
</DD>
<DT> <tt class="module">OIBTree</tt> </DT>
<DD>requires the values to be integers,
mapping Objects to Integers.
<P>
</DD>
<DT> <tt class="module">IIBTree</tt> </DT>
<DD>is strictest, requiring that both keys and values must be integers.
<P>
</DD>
</DL>
<P>
To use a B-tree, simply import the desired module and call the
constructor, always named <tt class="function">BTree()</tt>, to get a B-tree
instance, and then use it like any other mapping:
<P>
<dl><dd><pre class="verbatim">
import IIBTree
iimap = IIBTree.BTree()
iimap[1972] = 27
</pre></dl>
<P>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node38.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node36.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node40.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node38.html">5.2 ZODB.PersistentList</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node36.html">5 Related Modules</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node40.html">A. Resources</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1.2 OODBs vs. Relational DBs</title>
<META NAME="description" CONTENT="1.2 OODBs vs. Relational DBs">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node5.html">
<LINK REL="previous" HREF="node3.html">
<LINK REL="up" HREF="node2.html">
<LINK REL="next" HREF="node5.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node3.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node5.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node3.html">1.1 What is the</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node5.html">1.3 What is ZEO?</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000220000000000000000">
1.2 OODBs vs. Relational DBs</A>
</H2>
<P>
Another way to look at it is that the ZODB is a Python-specific
object-oriented database (OODB). Commercial object databases for C++
or Java often require that you jump through some hoops, such as using
a special preprocessor or avoiding certain data types. As we'll see,
the ZODB has some hoops of its own to jump through, but in comparison
the naturalness of the ZODB is astonishing.
<P>
Relational databases (RDBs) are far more common than OODBs.
Relational databases store information in tables; a table consists of
any number of rows, each row containing several columns of
information. (Rows are more formally called relations, which is where
the term ``relational database'' originates.)
<P>
Let's look at a concrete example. The example comes from my day job
working for the MEMS Exchange, in a greatly simplified version. The
job is to track process runs, which are lists of manufacturing steps
to be performed in a semiconductor fab. A run is owned by a
particular user, and has a name and assigned ID number. Runs consist
of a number of operations; an operation is a single step to be
performed, such as depositing something on a wafer or etching
something off it.
<P>
Operations may have parameters, which are additional information
required to perform an operation. For example, if you're depositing
something on a wafer, you need to know two things: 1) what you're
depositing, and 2) how much should be deposited. You might deposit
100 microns of silicon oxide, or 1 micron of copper.
<P>
Mapping these structures to a relational database is straightforward:
<P>
<dl><dd><pre class="verbatim">
CREATE TABLE runs (
int run_id,
varchar owner,
varchar title,
int acct_num,
primary key(run_id)
);
CREATE TABLE operations (
int run_id,
int step_num,
varchar process_id,
PRIMARY KEY(run_id, step_num),
FOREIGN KEY(run_id) REFERENCES runs(run_id),
);
CREATE TABLE parameters (
int run_id,
int step_num,
varchar param_name,
varchar param_value,
PRIMARY KEY(run_id, step_num, param_name)
FOREIGN KEY(run_id, step_num)
REFERENCES operations(run_id, step_num),
);
</pre></dl>
<P>
In Python, you would write three classes named <tt class="class">Run</tt>,
<tt class="class">Operation</tt>, and <tt class="class">Parameter</tt>. I won't present code for
defining these classes, since that code is uninteresting at this
point. Each class would contain a single method to begin with, an
<tt class="method">__init__</tt> method that assigns default values, such as 0 or
<code>None</code>, to each attribute of the class.
<P>
It's not difficult to write Python code that will create a <tt class="class">Run</tt>
instance and populate it with the data from the relational tables;
with a little more effort, you can build a straightforward tool,
usually called an object-relational mapper, to do this automatically.
(See
<a class="url" href="http://www.amk.ca/python/unmaintained/ordb.html">http://www.amk.ca/python/unmaintained/ordb.html</a> for a quick hack
at a Python object-relational mapper, and
<a class="url" href="http://www.python.org/workshops/1997-10/proceedings/shprentz.html">http://www.python.org/workshops/1997-10/proceedings/shprentz.html</a>for Joel Shprentz's more successful implementation of the same idea;
Unlike mine, Shprentz's system has been used for actual work.)
<P>
However, it is difficult to make an object-relational mapper
reasonably quick; a simple-minded implementation like mine is quite
slow because it has to do several queries to access all of an object's
data. Higher performance object-relational mappers cache objects to
improve performance, only performing SQL queries when they actually
need to.
<P>
That helps if you want to access run number 123 all of a sudden. But
what if you want to find all runs where a step has a parameter named
'thickness' with a value of 2.0? In the relational version, you have
two unappealing choices:
<P>
<OL>
<LI>Write a specialized SQL query for this case: <code>SELECT run_id
FROM operations WHERE param_name = 'thickness' AND param_value = 2.0</code>
<P>
If such queries are common, you can end up with lots of specialized
queries. When the database tables get rearranged, all these queries
will need to be modified.
<P>
</LI>
<LI>An object-relational mapper doesn't help much. Scanning
through the runs means that the the mapper will perform the required
SQL queries to read run #1, and then a simple Python loop can check
whether any of its steps have the parameter you're looking for.
Repeat for run #2, 3, and so forth. This does a vast
number of SQL queries, and therefore is incredibly slow.
<P>
</LI>
</OL>
<P>
An object database such as ZODB simply stores internal pointers from
object to object, so reading in a single object is much faster than
doing a bunch of SQL queries and assembling the results. Scanning all
runs, therefore, is still inefficient, but not grossly inefficient.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node3.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node5.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node3.html">1.1 What is the</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node5.html">1.3 What is ZEO?</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>A. Resources</title>
<META NAME="description" CONTENT="A. Resources">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node41.html">
<LINK REL="previous" HREF="node36.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node41.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node39.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node39.html">5.3 B-tree Modules</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000700000000000000000">
A. Resources</A>
</H1>
<P>
ZODB HOWTO, by Michel Pelletier:
<BR>
Goes into slightly more detail about the rules for writing applications using the ZODB.
<BR><a class="url" href="http://www.zope.org/Members/michel/HowTos/ZODB-How-To">http://www.zope.org/Members/michel/HowTos/ZODB-How-To</a>
<P>
Introduction to the Zope Object Database, by Jim Fulton:
<BR>
Goes into much greater detail, explaining advanced uses of the ZODB and
how it's actually implemented. A definitive reference, and highly recommended.
<BR><a class="url" href="http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html">http://www.python.org/workshops/2000-01/proceedings/papers/fulton/zodb3.html</a>
<P>
Download link for ZEO:
<BR><a class="url" href="http://www.zope.org/Products/ZEO/">http://www.zope.org/Products/ZEO/</a>
<P>
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node39.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node39.html">5.3 B-tree Modules</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B. GNU Free Documentation License</title>
<META NAME="description" CONTENT="B. GNU Free Documentation License">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" href="about.html">
<LINK REL="previous" HREF="node40.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node42.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node40.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node42.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node40.html">A. Resources</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node42.html">Preamble</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000800000000000000000">
B. GNU Free Documentation License</A>
</H1>
<P>
Version 1.1, March 2000
<BR>
<P>
Copyright <SPAN CLASS="MATH"><IMG
WIDTH="20" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img1.gif"
ALT="$\copyright$"></SPAN> 2000 Free Software Foundation, Inc.
<BR>
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
<BR>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node42.html">Preamble</a>
<LI><A href="node43.html">B..1 Applicability and Definitions</a>
<LI><A href="node44.html">B..2 Verbatim Copying</a>
<LI><A href="node45.html">B..3 Copying in Quantity</a>
<LI><A href="node46.html">B..4 Modifications</a>
<LI><A href="node47.html">B..5 Combining Documents</a>
<LI><A href="node48.html">B..6 Collections of Documents</a>
<LI><A href="node49.html">B..7 Aggregation With Independent Works</a>
<LI><A href="node50.html">B..8 Translation</a>
<LI><A href="node51.html">B..9 Termination</a>
<LI><A href="node52.html">B..10 Future Revisions of This Licence</a>
<LI><A href="node53.html">ADDENDUM: How to use this License for your documents</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node40.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node42.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node40.html">A. Resources</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node42.html">Preamble</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Preamble</title>
<META NAME="description" CONTENT="Preamble">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node43.html">
<LINK REL="previous" HREF="node41.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node43.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node41.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node43.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node43.html">B..1 Applicability and Definitions</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000810000000000000000">
Preamble</A>
</H2>
<P>
The purpose of this License is to make a manual, textbook, or other
written document ``free'' in the sense of freedom: to assure everyone
the effective freedom to copy and redistribute it, with or without
modifying it, either commercially or noncommercially. Secondarily,
this License preserves for the author and publisher a way to get
credit for their work, while not being considered responsible for
modifications made by others.
<P>
This License is a kind of ``copyleft'', which means that derivative
works of the document must themselves be free in the same sense. It
complements the GNU General Public License, which is a copyleft
license designed for free software.
<P>
We have designed this License in order to use it for manuals for free
software, because free software needs free documentation: a free
program should come with manuals providing the same freedoms that the
software does. But this License is not limited to software manuals;
it can be used for any textual work, regardless of subject matter or
whether it is published as a printed book. We recommend this License
principally for works whose purpose is instruction or reference.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node41.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node43.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node43.html">B..1 Applicability and Definitions</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..1 Applicability and Definitions</title>
<META NAME="description" CONTENT="B..1 Applicability and Definitions">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node44.html">
<LINK REL="previous" HREF="node42.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node44.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node42.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node44.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node42.html">Preamble</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node44.html">B..2 Verbatim Copying</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000820000000000000000">
B..1 Applicability and Definitions</A>
</H2>
<P>
This License applies to any manual or other work that contains a
notice placed by the copyright holder saying it can be distributed
under the terms of this License. The ``Document'', below, refers to any
such manual or work. Any member of the public is a licensee, and is
addressed as ``you''.
<P>
A ``Modified Version'' of the Document means any work containing the
Document or a portion of it, either copied verbatim, or with
modifications and/or translated into another language.
<P>
A ``Secondary Section'' is a named appendix or a front-matter section of
the Document that deals exclusively with the relationship of the
publishers or authors of the Document to the Document's overall subject
(or to related matters) and contains nothing that could fall directly
within that overall subject. (For example, if the Document is in part a
textbook of mathematics, a Secondary Section may not explain any
mathematics.) The relationship could be a matter of historical
connection with the subject or with related matters, or of legal,
commercial, philosophical, ethical or political position regarding
them.
<P>
The ``Invariant Sections'' are certain Secondary Sections whose titles
are designated, as being those of Invariant Sections, in the notice
that says that the Document is released under this License.
<P>
The ``Cover Texts'' are certain short passages of text that are listed,
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
the Document is released under this License.
<P>
A ``Transparent'' copy of the Document means a machine-readable copy,
represented in a format whose specification is available to the
general public, whose contents can be viewed and edited directly and
straightforwardly with generic text editors or (for images composed of
pixels) generic paint programs or (for drawings) some widely available
drawing editor, and that is suitable for input to text formatters or
for automatic translation to a variety of formats suitable for input
to text formatters. A copy made in an otherwise Transparent file
format whose markup has been designed to thwart or discourage
subsequent modification by readers is not Transparent. A copy that is
not ``Transparent'' is called ``Opaque''.
<P>
Examples of suitable formats for Transparent copies include plain
ASCII without markup, Texinfo input format, <SPAN CLASS="logo,LaTeX">L<SUP><SMALL>A</SMALL></SUP>T<SMALL>E</SMALL>X</SPAN>&nbsp;input format, SGML
or XML using a publicly available DTD, and standard-conforming simple
HTML designed for human modification. Opaque formats include
PostScript, PDF, proprietary formats that can be read and edited only
by proprietary word processors, SGML or XML for which the DTD and/or
processing tools are not generally available, and the
machine-generated HTML produced by some word processors for output
purposes only.
<P>
The ``Title Page'' means, for a printed book, the title page itself,
plus such following pages as are needed to hold, legibly, the material
this License requires to appear in the title page. For works in
formats which do not have any title page as such, ``Title Page'' means
the text near the most prominent appearance of the work's title,
preceding the beginning of the body of the text.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node42.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node44.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node42.html">Preamble</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node44.html">B..2 Verbatim Copying</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..2 Verbatim Copying</title>
<META NAME="description" CONTENT="B..2 Verbatim Copying">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node45.html">
<LINK REL="previous" HREF="node43.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node45.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node43.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node45.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node43.html">B..1 Applicability and Definitions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node45.html">B..3 Copying in Quantity</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000830000000000000000">
B..2 Verbatim Copying</A>
</H2>
<P>
You may copy and distribute the Document in any medium, either
commercially or noncommercially, provided that this License, the
copyright notices, and the license notice saying this License applies
to the Document are reproduced in all copies, and that you add no other
conditions whatsoever to those of this License. You may not use
technical measures to obstruct or control the reading or further
copying of the copies you make or distribute. However, you may accept
compensation in exchange for copies. If you distribute a large enough
number of copies you must also follow the conditions in section 3.
<P>
You may also lend copies, under the same conditions stated above, and
you may publicly display copies.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node43.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node45.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node43.html">B..1 Applicability and Definitions</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node45.html">B..3 Copying in Quantity</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..3 Copying in Quantity</title>
<META NAME="description" CONTENT="B..3 Copying in Quantity">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node46.html">
<LINK REL="previous" HREF="node44.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node46.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node44.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node46.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node44.html">B..2 Verbatim Copying</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node46.html">B..4 Modifications</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000840000000000000000">
B..3 Copying in Quantity</A>
</H2>
<P>
If you publish printed copies of the Document numbering more than 100,
and the Document's license notice requires Cover Texts, you must enclose
the copies in covers that carry, clearly and legibly, all these Cover
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
the back cover. Both covers must also clearly and legibly identify
you as the publisher of these copies. The front cover must present
the full title with all words of the title equally prominent and
visible. You may add other material on the covers in addition.
Copying with changes limited to the covers, as long as they preserve
the title of the Document and satisfy these conditions, can be treated
as verbatim copying in other respects.
<P>
If the required texts for either cover are too voluminous to fit
legibly, you should put the first ones listed (as many as fit
reasonably) on the actual cover, and continue the rest onto adjacent
pages.
<P>
If you publish or distribute Opaque copies of the Document numbering
more than 100, you must either include a machine-readable Transparent
copy along with each Opaque copy, or state in or with each Opaque copy
a publicly-accessible computer-network location containing a complete
Transparent copy of the Document, free of added material, which the
general network-using public has access to download anonymously at no
charge using public-standard network protocols. If you use the latter
option, you must take reasonably prudent steps, when you begin
distribution of Opaque copies in quantity, to ensure that this
Transparent copy will remain thus accessible at the stated location
until at least one year after the last time you distribute an Opaque
copy (directly or through your agents or retailers) of that edition to
the public.
<P>
It is requested, but not required, that you contact the authors of the
Document well before redistributing any large number of copies, to give
them a chance to provide you with an updated version of the Document.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node44.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node46.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node44.html">B..2 Verbatim Copying</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node46.html">B..4 Modifications</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..4 Modifications</title>
<META NAME="description" CONTENT="B..4 Modifications">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node47.html">
<LINK REL="previous" HREF="node45.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node47.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node45.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node47.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node45.html">B..3 Copying in Quantity</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node47.html">B..5 Combining Documents</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000850000000000000000">
B..4 Modifications</A>
</H2>
<P>
You may copy and distribute a Modified Version of the Document under
the conditions of sections 2 and 3 above, provided that you release
the Modified Version under precisely this License, with the Modified
Version filling the role of the Document, thus licensing distribution
and modification of the Modified Version to whoever possesses a copy
of it. In addition, you must do these things in the Modified Version:
<P>
<UL>
<LI>Use in the Title Page (and on the covers, if any) a title distinct
from that of the Document, and from those of previous versions
(which should, if there were any, be listed in the History section
of the Document). You may use the same title as a previous version
if the original publisher of that version gives permission.
</LI>
<LI>List on the Title Page, as authors, one or more persons or entities
responsible for authorship of the modifications in the Modified
Version, together with at least five of the principal authors of the
Document (all of its principal authors, if it has less than five).
</LI>
<LI>State on the Title page the name of the publisher of the
Modified Version, as the publisher.
</LI>
<LI>Preserve all the copyright notices of the Document.
</LI>
<LI>Add an appropriate copyright notice for your modifications
adjacent to the other copyright notices.
</LI>
<LI>Include, immediately after the copyright notices, a license notice
giving the public permission to use the Modified Version under the
terms of this License, in the form shown in the Addendum below.
</LI>
<LI>Preserve in that license notice the full lists of Invariant Sections
and required Cover Texts given in the Document's license notice.
</LI>
<LI>Include an unaltered copy of this License.
</LI>
<LI>Preserve the section entitled ``History'', and its title, and add to
it an item stating at least the title, year, new authors, and
publisher of the Modified Version as given on the Title Page. If
there is no section entitled ``History'' in the Document, create one
stating the title, year, authors, and publisher of the Document as
given on its Title Page, then add an item describing the Modified
Version as stated in the previous sentence.
</LI>
<LI>Preserve the network location, if any, given in the Document for
public access to a Transparent copy of the Document, and likewise
the network locations given in the Document for previous versions
it was based on. These may be placed in the ``History'' section.
You may omit a network location for a work that was published at
least four years before the Document itself, or if the original
publisher of the version it refers to gives permission.
</LI>
<LI>In any section entitled ``Acknowledgements'' or ``Dedications'',
preserve the section's title, and preserve in the section all the
substance and tone of each of the contributor acknowledgements
and/or dedications given therein.
</LI>
<LI>Preserve all the Invariant Sections of the Document,
unaltered in their text and in their titles. Section numbers
or the equivalent are not considered part of the section titles.
</LI>
<LI>Delete any section entitled ``Endorsements''. Such a section
may not be included in the Modified Version.
</LI>
<LI>Do not retitle any existing section as ``Endorsements''
or to conflict in title with any Invariant Section.
<P>
</LI>
</UL>
<P>
If the Modified Version includes new front-matter sections or
appendices that qualify as Secondary Sections and contain no material
copied from the Document, you may at your option designate some or all
of these sections as invariant. To do this, add their titles to the
list of Invariant Sections in the Modified Version's license notice.
These titles must be distinct from any other section titles.
<P>
You may add a section entitled ``Endorsements'', provided it contains
nothing but endorsements of your Modified Version by various
parties - for example, statements of peer review or that the text has
been approved by an organization as the authoritative definition of a
standard.
<P>
You may add a passage of up to five words as a Front-Cover Text, and a
passage of up to 25 words as a Back-Cover Text, to the end of the list
of Cover Texts in the Modified Version. Only one passage of
Front-Cover Text and one of Back-Cover Text may be added by (or
through arrangements made by) any one entity. If the Document already
includes a cover text for the same cover, previously added by you or
by arrangement made by the same entity you are acting on behalf of,
you may not add another; but you may replace the old one, on explicit
permission from the previous publisher that added the old one.
<P>
The author(s) and publisher(s) of the Document do not by this License
give permission to use their names for publicity for or to assert or
imply endorsement of any Modified Version.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node45.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node47.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node45.html">B..3 Copying in Quantity</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node47.html">B..5 Combining Documents</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..5 Combining Documents</title>
<META NAME="description" CONTENT="B..5 Combining Documents">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node48.html">
<LINK REL="previous" HREF="node46.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node48.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node46.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node48.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node46.html">B..4 Modifications</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node48.html">B..6 Collections of Documents</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000860000000000000000">
B..5 Combining Documents</A>
</H2>
<P>
You may combine the Document with other documents released under this
License, under the terms defined in section 4 above for modified
versions, provided that you include in the combination all of the
Invariant Sections of all of the original documents, unmodified, and
list them all as Invariant Sections of your combined work in its
license notice.
<P>
The combined work need only contain one copy of this License, and
multiple identical Invariant Sections may be replaced with a single
copy. If there are multiple Invariant Sections with the same name but
different contents, make the title of each such section unique by
adding at the end of it, in parentheses, the name of the original
author or publisher of that section if known, or else a unique number.
Make the same adjustment to the section titles in the list of
Invariant Sections in the license notice of the combined work.
<P>
In the combination, you must combine any sections entitled ``History''
in the various original documents, forming one section entitled
``History''; likewise combine any sections entitled ``Acknowledgements'',
and any sections entitled ``Dedications''. You must delete all sections
entitled ``Endorsements.''
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node46.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node48.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node46.html">B..4 Modifications</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node48.html">B..6 Collections of Documents</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..6 Collections of Documents</title>
<META NAME="description" CONTENT="B..6 Collections of Documents">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node49.html">
<LINK REL="previous" HREF="node47.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node49.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node47.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node49.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node47.html">B..5 Combining Documents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node49.html">B..7 Aggregation With Independent</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000870000000000000000">
B..6 Collections of Documents</A>
</H2>
<P>
You may make a collection consisting of the Document and other documents
released under this License, and replace the individual copies of this
License in the various documents with a single copy that is included in
the collection, provided that you follow the rules of this License for
verbatim copying of each of the documents in all other respects.
<P>
You may extract a single document from such a collection, and distribute
it individually under this License, provided you insert a copy of this
License into the extracted document, and follow this License in all
other respects regarding verbatim copying of that document.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node47.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node49.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node47.html">B..5 Combining Documents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node49.html">B..7 Aggregation With Independent</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..7 Aggregation With Independent Works</title>
<META NAME="description" CONTENT="B..7 Aggregation With Independent Works">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node50.html">
<LINK REL="previous" HREF="node48.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node50.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node48.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node50.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node48.html">B..6 Collections of Documents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node50.html">B..8 Translation</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000880000000000000000">
B..7 Aggregation With Independent Works</A>
</H2>
<P>
A compilation of the Document or its derivatives with other separate
and independent documents or works, in or on a volume of a storage or
distribution medium, does not as a whole count as a Modified Version
of the Document, provided no compilation copyright is claimed for the
compilation. Such a compilation is called an ``aggregate'', and this
License does not apply to the other self-contained works thus compiled
with the Document, on account of their being thus compiled, if they
are not themselves derivative works of the Document.
<P>
If the Cover Text requirement of section 3 is applicable to these
copies of the Document, then if the Document is less than one quarter
of the entire aggregate, the Document's Cover Texts may be placed on
covers that surround only the Document within the aggregate.
Otherwise they must appear on covers around the whole aggregate.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node48.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node50.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node48.html">B..6 Collections of Documents</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node50.html">B..8 Translation</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1.3 What is ZEO?</title>
<META NAME="description" CONTENT="1.3 What is ZEO?">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node6.html">
<LINK REL="previous" HREF="node4.html">
<LINK REL="up" HREF="node2.html">
<LINK REL="next" HREF="node6.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node4.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node6.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node4.html">1.2 OODBs vs. Relational</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node6.html">1.4 About this guide</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000230000000000000000">
1.3 What is ZEO?</A>
</H2>
<P>
The ZODB comes with a few different classes that implement the
<tt class="class">Storage</tt> interface. Such classes handle the job of
writing out Python objects to a physical storage medium, which can be
a disk file (the <tt class="class">FileStorage</tt> class), a BerkeleyDB file
(<tt class="class">BerkeleyStorage</tt>), a relational database
(<tt class="class">DCOracleStorage</tt>), or some other medium. ZEO adds
<tt class="class">ClientStorage</tt>, a new <tt class="class">Storage</tt> that doesn't write to
physical media but just forwards all requests across a network to a
server. The server, which is running an instance of the
<tt class="class">StorageServer</tt> class, simply acts as a front-end for some
physical <tt class="class">Storage</tt> class. It's a fairly simple idea, but as
we'll see later on in this document, it opens up many possibilities.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node4.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node6.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node4.html">1.2 OODBs vs. Relational</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node6.html">1.4 About this guide</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..8 Translation</title>
<META NAME="description" CONTENT="B..8 Translation">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node51.html">
<LINK REL="previous" HREF="node49.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node51.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node49.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node51.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node49.html">B..7 Aggregation With Independent</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node51.html">B..9 Termination</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000890000000000000000">
B..8 Translation</A>
</H2>
<P>
Translation is considered a kind of modification, so you may
distribute translations of the Document under the terms of section 4.
Replacing Invariant Sections with translations requires special
permission from their copyright holders, but you may include
translations of some or all Invariant Sections in addition to the
original versions of these Invariant Sections. You may include a
translation of this License provided that you also include the
original English version of this License. In case of a disagreement
between the translation and the original English version of this
License, the original English version will prevail.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node49.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node51.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node49.html">B..7 Aggregation With Independent</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node51.html">B..9 Termination</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..9 Termination</title>
<META NAME="description" CONTENT="B..9 Termination">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node52.html">
<LINK REL="previous" HREF="node50.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node52.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node50.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node52.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node50.html">B..8 Translation</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node52.html">B..10 Future Revisions of</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0008100000000000000000">
B..9 Termination</A>
</H2>
<P>
You may not copy, modify, sublicense, or distribute the Document except
as expressly provided for under this License. Any other attempt to
copy, modify, sublicense or distribute the Document is void, and will
automatically terminate your rights under this License. However,
parties who have received copies, or rights, from you under this
License will not have their licenses terminated so long as such
parties remain in full compliance.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node50.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node52.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node50.html">B..8 Translation</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node52.html">B..10 Future Revisions of</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>B..10 Future Revisions of This Licence</title>
<META NAME="description" CONTENT="B..10 Future Revisions of This Licence">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node53.html">
<LINK REL="previous" HREF="node51.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" HREF="node53.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node51.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node53.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node51.html">B..9 Termination</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node53.html">ADDENDUM: How to use</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0008110000000000000000">
B..10 Future Revisions of This Licence</A>
</H2>
<P>
The Free Software Foundation may publish new, revised versions
of the GNU Free Documentation License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns. See
<a class="url" href="http://www.gnu.org/copyleft/">http://www.gnu.org/copyleft/</a>.
<P>
Each version of the License is given a distinguishing version number.
If the Document specifies that a particular numbered version of this
License "or any later version" applies to it, you have the option of
following the terms and conditions either of that specified version or
of any later version that has been published (not as a draft) by the
Free Software Foundation. If the Document does not specify a version
number of this License, you may choose any version ever published (not
as a draft) by the Free Software Foundation.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node51.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node53.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node51.html">B..9 Termination</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node53.html">ADDENDUM: How to use</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ADDENDUM: How to use this License for your documents</title>
<META NAME="description" CONTENT="ADDENDUM: How to use this License for your documents">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node52.html">
<LINK REL="up" HREF="node41.html">
<LINK REL="next" href="about.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node52.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="about.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node52.html">B..10 Future Revisions of</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" href="about.html">About this document ...</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION0008120000000000000000">
ADDENDUM: How to use this License for your documents</A>
</H2>
<P>
To use this License in a document you have written, include a copy of
the License in the document and put the following copyright and
license notices just after the title page:
<P>
<P>
<BLOCKQUOTE>Copyright <SPAN CLASS="MATH"><IMG
WIDTH="20" HEIGHT="29" ALIGN="MIDDLE" BORDER="0"
SRC="img1.gif"
ALT="$\copyright$"></SPAN> YEAR YOUR NAME.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with the Invariant Sections being LIST THEIR TITLES, with the
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
A copy of the license is included in the section entitled ``GNU
Free Documentation License''.
</BLOCKQUOTE>
<P>
<P>
If you have no Invariant Sections, write ``with no Invariant Sections''
instead of saying which ones are invariant. If you have no
Front-Cover Texts, write ``no Front-Cover Texts'' instead of
``Front-Cover Texts being LIST''; likewise for Back-Cover Texts.
<P>
If your document contains nontrivial examples of program code, we
recommend releasing these examples in parallel under your choice of
free software license, such as the GNU General Public License,
to permit their use in free software.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node52.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node41.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A href="about.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node52.html">B..10 Future Revisions of</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node41.html">B. GNU Free Documentation</A>
<b class="navlabel">Next:</b> <a class="sectref" href="about.html">About this document ...</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1.4 About this guide</title>
<META NAME="description" CONTENT="1.4 About this guide">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node7.html">
<LINK REL="previous" HREF="node5.html">
<LINK REL="up" HREF="node2.html">
<LINK REL="next" HREF="node7.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node5.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node7.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node5.html">1.3 What is ZEO?</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node7.html">1.5 Acknowledgements</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000240000000000000000">
1.4 About this guide</A>
</H2>
<P>
The primary author of this guide works on a project which uses the
ZODB and ZEO as its primary storage technology. We use the ZODB to
store process runs and operations, a catalog of available processes,
user information, accounting information, and other data. Part of the
goal of writing this document is to make our experience more widely
available. A few times we've spent hours or even days trying to
figure out a problem, and this guide is an attempt to gather up the
knowledge we've gained so that others don't have to make the same
mistakes we did while learning.
<P>
This document will always be a work in progress. If you wish to
suggest clarifications or additional topics, please send your comments to
<span class="email">akuchlin@mems-exchange.org</span>.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node5.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node7.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node5.html">1.3 What is ZEO?</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node7.html">1.5 Acknowledgements</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>1.5 Acknowledgements</title>
<META NAME="description" CONTENT="1.5 Acknowledgements">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="previous" HREF="node6.html">
<LINK REL="up" HREF="node2.html">
<LINK REL="next" HREF="node8.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node6.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node6.html">1.4 About this guide</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000250000000000000000">
1.5 Acknowledgements</A>
</H2>
<P>
I'd like to thank the people who've pointed out inaccuracies and bugs,
offered suggestions on the text, or proposed new topics that should be
covered: Jeff Bauer, Willem Broekema, Thomas Guettler,
Chris McDonough, George Runyan.
<P>
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node6.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node2.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node6.html">1.4 About this guide</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node2.html">1 Introduction</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2 ZODB Programming</title>
<META NAME="description" CONTENT="2 ZODB Programming">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" href="zeo.html">
<LINK REL="previous" HREF="node2.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node9.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node7.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node7.html">1.5 Acknowledgements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000300000000000000000">
2 ZODB Programming</A>
</H1>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node9.html">2.1 Installing ZODB</a>
<UL>
<LI><A href="node10.html">2.1.1 Requirements</a>
<LI><A href="node11.html">2.1.2 Installing the Packages</a>
</ul>
<LI><A href="node12.html">2.2 How ZODB Works</a>
<LI><A href="node13.html">2.3 Opening a ZODB</a>
<LI><A href="node14.html">2.4 Writing a Persistent Class</a>
<LI><A href="node15.html">2.5 Rules for Writing Persistent Classes</a>
<UL>
<LI><A href="node16.html">2.5.1 Modifying Mutable Objects</a>
<LI><A href="node17.html">2.5.2 Some Special Methods Don't Work</a>
<LI><A href="node18.html">2.5.3 Fixing <tt class="function">isinstance</tt> and <tt class="function">issubclass</tt></a>
<LI><A href="node19.html">2.5.4 <tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, and <tt class="method">__setattr__</tt></a>
</ul>
<LI><A href="node20.html">2.6 Writing Persistent Classes</a>
<UL>
<LI><A href="node21.html">2.6.1 Changing Instance Attributes</a>
</ul></ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node7.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node9.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node7.html">1.5 Acknowledgements</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node9.html">2.1 Installing ZODB</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>2.1 Installing ZODB</title>
<META NAME="description" CONTENT="2.1 Installing ZODB">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node12.html">
<LINK REL="previous" HREF="node8.html">
<LINK REL="up" HREF="node8.html">
<LINK REL="next" HREF="node10.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node8.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node10.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node10.html">2.1.1 Requirements</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H2><A NAME="SECTION000310000000000000000">
2.1 Installing ZODB</A>
</H2>
<P>
The ZODB forms part of Zope, but it's difficult and somewhat painful
to extract the bits from Zope needed to support just the ZODB.
Therefore I've assembled a distribution containing only the packages
required to use the ZODB and ZEO, so you can install it and start
programming right away.
<P>
To download the distribution, go to my ZODB page at
<a class="url" href="http://www.amk.ca/zodb/">http://www.amk.ca/zodb/</a>.
The distribution is still experimental, so don't be surprised if the
installation process runs into problems. Please inform me of any
difficulties you encounter.
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node10.html">2.1.1 Requirements</a>
<LI><A href="node11.html">2.1.2 Installing the Packages</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node8.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="node8.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node10.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="node8.html">2 ZODB Programming</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node10.html">2.1.1 Requirements</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>3 ZEO</title>
<META NAME="description" CONTENT="3 ZEO">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" HREF="node31.html">
<LINK REL="previous" HREF="node8.html">
<LINK REL="up" HREF="zodb.html">
<LINK REL="next" HREF="node23.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node21.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node23.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node21.html">2.6.1 Changing Instance Attributes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node23.html">3.1 How ZEO Works</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<H1><A NAME="SECTION000400000000000000000">&nbsp;</A>
<BR>
3 ZEO
</H1>
<P>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></a>
<UL>
<LI><A href="node23.html">3.1 How ZEO Works</a>
<LI><A href="node24.html">3.2 Installing ZEO</a>
<UL>
<LI><A href="node25.html">3.2.1 Requirements</a>
<LI><A href="node26.html">3.2.2 Installation</a>
</ul>
<LI><A href="node27.html">3.3 Configuring and Running a ZEO Server</a>
<LI><A href="node28.html">3.4 Testing the ZEO Installation</a>
<LI><A href="node29.html">3.5 ZEO Programming Notes</a>
<LI><A href="node30.html">3.6 Sample Application: chatter.py</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><A HREF="node21.html"><img src="/python/writing/icons/previous.gif"
border="0" height="32"
alt="Previous Page" width="32"></A></td>
<td><A HREF="zodb.html"><img src="/python/writing/icons/up.gif"
border="0" height="32"
alt="Up One Level" width="32"></A></td>
<td><A HREF="node23.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Previous:</b> <a class="sectref" HREF="node21.html">2.6.1 Changing Instance Attributes</A>
<b class="navlabel">Up:</b> <a class="sectref" HREF="zodb.html">ZODB/ZEO Programming Guide</A>
<b class="navlabel">Next:</b> <a class="sectref" HREF="node23.html">3.1 How ZEO Works</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
/*
* The first part of this is the standard CSS generated by LaTeX2HTML,
* with the "empty" declarations removed.
*/
/* Century Schoolbook font is very similar to Computer Modern Math: cmmi */
.math { font-family: "Century Schoolbook", serif; }
.math i { font-family: "Century Schoolbook", serif;
font-weight: bold }
.boldmath { font-family: "Century Schoolbook", serif;
font-weight: bold }
/*
* Implement both fixed-size and relative sizes.
*
* I think these can be safely removed, as it doesn't appear that
* LaTeX2HTML ever generates these, even though these are carried
* over from the LaTeX2HTML stylesheet.
*/
small.xtiny { font-size : xx-small; }
small.tiny { font-size : x-small; }
small.scriptsize { font-size : smaller; }
small.footnotesize { font-size : small; }
big.xlarge { font-size : large; }
big.xxlarge { font-size : x-large; }
big.huge { font-size : larger; }
big.xhuge { font-size : xx-large; }
/*
* Document-specific styles come next;
* these are added for the Python documentation.
*
* Note that the size specifications for the H* elements are because
* Netscape on Solaris otherwise doesn't get it right; they all end up
* the normal text size.
*/
body { color: #000000;
background-color: #ffffff; }
a:active { color: #ff0000; }
a:visited { color: #551a8b; }
a:link { color: #0000bb; }
h1, h2, h3, h4, h5, h6 { font-family: avantgarde, sans-serif;
font-weight: bold; }
h1 { font-size: 180%; }
h2 { font-size: 150%; }
h3, h4 { font-size: 120%; }
code, tt { font-family: lucida typewriter, lucidatypewriter,
monospace; }
var { font-family: times, serif;
font-style: italic;
font-weight: normal; }
.typelabel { font-family: lucida, sans-serif; }
.navigation td { background-color: #99ccff;
font-weight: bold;
font-family: avantgarde, sans-serif;
font-size: 110%; }
.release-info { font-style: italic; }
.titlegraphic { vertical-align: top; }
.verbatim { color: #00008b;
font-family: lucida typewriter, lucidatypewriter,
monospace; }
.grammar { background-color: #99ccff;
margin-right: 0.5in;
padding: 0.05in; }
.productions { background-color: #bbeeff; }
.productions table { vertical-align: baseline; }
.grammar-footer { padding: 0.05in;
font-size: 85%; }
.email { font-family: avantgarde, sans-serif; }
.mailheader { font-family: avantgarde, sans-serif; }
.mimetype { font-family: avantgarde, sans-serif; }
.newsgroup { font-family: avantgarde, sans-serif; }
.url { font-family: avantgarde, sans-serif; }
.file { font-family: avantgarde, sans-serif; }
.tableheader { background-color: #99ccff;
font-family: avantgarde, sans-serif; }
.refcount-info { font-style: italic; }
.refcount-info .value { font-weight: bold;
color: #006600; }
/*
* Some decoration for the "See also:" blocks, in part inspired by some of
* the styling on Lars Marius Garshol's XSA pages.
* (The blue in the navigation bars is #99CCFF.)
*/
.seealso { background-color: #fffaf0;
border: thin solid black;
padding: 4pt; }
.seealso .heading { font-size: 110%; }
/*
* Class 'availability' is used for module availability statements at
* the top of modules.
*/
.availability .platform { font-weight: bold; }
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>ZODB/ZEO Programming Guide</title>
<META NAME="description" CONTENT="ZODB/ZEO Programming Guide">
<META NAME="keywords" CONTENT="zodb">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">
<meta http-equiv="Content-Type" content="text/html; charset=">
<link rel="STYLESHEET" href="zodb.css">
<link rel="first" href="zodb.html">
<link rel="contents" href="contents.html" title="Contents">
<LINK REL="next" href="contents.html">
</head>
<body>
<DIV CLASS="navigation">
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><A href="contents.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Next:</b> <a class="sectref" href="contents.html">Contents</A>
<br><hr>
</DIV>
<!--End of Navigation Panel-->
<div class="titlepage">
<center>
<h1>ZODB/ZEO Programming Guide</h1>
<p><b><font size="+2">A.M. Kuchling</font></b></p>
<p>akuchlin@mems-exchange.org</p>
<p><strong>Release 0.03</strong><br>
<strong>February 8, 2002</strong></p>
<p>
</center>
</div>
<p><hr>
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"></a>
<UL>
<LI><A href="contents.html">Contents</a>
<LI><A href="node2.html">1 Introduction</a>
<UL>
<LI><A href="node3.html">1.1 What is the ZODB?</a>
<LI><A href="node4.html">1.2 OODBs vs. Relational DBs</a>
<LI><A href="node5.html">1.3 What is ZEO?</a>
<LI><A href="node6.html">1.4 About this guide</a>
<LI><A href="node7.html">1.5 Acknowledgements</a>
</ul>
<LI><A href="node8.html">2 ZODB Programming</a>
<UL>
<LI><A href="node9.html">2.1 Installing ZODB</a>
<UL>
<LI><A href="node10.html">2.1.1 Requirements</a>
<LI><A href="node11.html">2.1.2 Installing the Packages</a>
</ul>
<LI><A href="node12.html">2.2 How ZODB Works</a>
<LI><A href="node13.html">2.3 Opening a ZODB</a>
<LI><A href="node14.html">2.4 Writing a Persistent Class</a>
<LI><A href="node15.html">2.5 Rules for Writing Persistent Classes</a>
<UL>
<LI><A href="node16.html">2.5.1 Modifying Mutable Objects</a>
<LI><A href="node17.html">2.5.2 Some Special Methods Don't Work</a>
<LI><A href="node18.html">2.5.3 Fixing <tt class="function">isinstance</tt> and <tt class="function">issubclass</tt></a>
<LI><A href="node19.html">2.5.4 <tt class="method">__getattr__</tt>, <tt class="method">__delattr__</tt>, and <tt class="method">__setattr__</tt></a>
</ul>
<LI><A href="node20.html">2.6 Writing Persistent Classes</a>
<UL>
<LI><A href="node21.html">2.6.1 Changing Instance Attributes</a>
</ul>
</ul>
<LI><A href="zeo.html">3 ZEO</a>
<UL>
<LI><A href="node23.html">3.1 How ZEO Works</a>
<LI><A href="node24.html">3.2 Installing ZEO</a>
<UL>
<LI><A href="node25.html">3.2.1 Requirements</a>
<LI><A href="node26.html">3.2.2 Installation</a>
</ul>
<LI><A href="node27.html">3.3 Configuring and Running a ZEO Server</a>
<LI><A href="node28.html">3.4 Testing the ZEO Installation</a>
<LI><A href="node29.html">3.5 ZEO Programming Notes</a>
<LI><A href="node30.html">3.6 Sample Application: chatter.py</a>
</ul>
<LI><A href="node31.html">4 Transactions and Versioning</a>
<UL>
<LI><A href="node32.html">4.1 Subtransactions</a>
<LI><A href="node33.html">4.2 Undoing Changes</a>
<LI><A href="node34.html">4.3 Versions</a>
<LI><A href="node35.html">4.4 Multithreaded ZODB Programs</a>
</ul>
<LI><A href="node36.html">5 Related Modules</a>
<UL>
<LI><A href="node37.html">5.1 <tt class="module">ZODB.PersistentMapping</tt></a>
<LI><A href="node38.html">5.2 <tt class="module">ZODB.PersistentList</tt></a>
<LI><A href="node39.html">5.3 B-tree Modules</a>
</ul>
<LI><A href="node40.html">A. Resources</a>
<LI><A href="node41.html">B. GNU Free Documentation License</a>
<UL>
<LI><A href="node42.html">Preamble</a>
<LI><A href="node43.html">B..1 Applicability and Definitions</a>
<LI><A href="node44.html">B..2 Verbatim Copying</a>
<LI><A href="node45.html">B..3 Copying in Quantity</a>
<LI><A href="node46.html">B..4 Modifications</a>
<LI><A href="node47.html">B..5 Combining Documents</a>
<LI><A href="node48.html">B..6 Collections of Documents</a>
<LI><A href="node49.html">B..7 Aggregation With Independent Works</a>
<LI><A href="node50.html">B..8 Translation</a>
<LI><A href="node51.html">B..9 Termination</a>
<LI><A href="node52.html">B..10 Future Revisions of This Licence</a>
<LI><A href="node53.html">ADDENDUM: How to use this License for your documents</a>
</ul>
<LI><A href="about.html">About this document ...</a>
</ul>
<!--End of Table of Child-Links-->
<DIV CLASS="navigation">
<p><hr>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><A href="contents.html"><img src="/python/writing/icons/next.gif"
border="0" height="32"
alt="Next Page" width="32"></A></td>
<td align="center" width="100%">ZODB/ZEO Programming Guide</td>
<td><A href="contents.html"><img src="/python/writing/icons/contents.gif"
border="0" height="32"
alt="Contents" width="32"></A></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
<td><img src="/python/writing/icons/blank.gif"
border="0" height="32"
alt="" width="32"></td>
</tr></table>
<b class="navlabel">Next:</b> <a class="sectref" href="contents.html">Contents</A>
<hr>
<span class="release-info">Release 0.03, documentation updated on February 8, 2002.</span>
</DIV>
<!--End of Navigation Panel-->
</BODY>
</HTML>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment