The Zope Object Database (ZODB) is an
object-oriented database for transparently and persistently storing
Python objects. It is included as part of the
Zope
Zope is a family of free and open-source web application servers written in Python, and their associated online community. Zope stands for "Z Object Publishing Environment", and was the first system using the now common object publishing method ...
web
application server, but can also be used independently of Zope.
Features of the ZODB include: transactions, history/undo, transparently pluggable storage, built-in caching,
multiversion concurrency control
Multiversion concurrency control (MCC or MVCC), is a concurrency control method commonly used by database management systems to provide concurrent access to the database and in programming languages to implement transactional memory.
Descriptio ...
(MVCC), and scalability across a network (using ).
History
* Created by Jim Fulton of Zope Corporation in the late 90s.
* Started as simple Persistent Object System (POS) during Principia development (which later became Zope)
* ZODB 3 was renamed when a significant architecture change was landed.
* ZODB 4 was a short lived project to re-implement the entire ZODB 3 package using 100% Python.
Implementation
Basics
ZODB stores Python objects using an extended version of Python's built-in object persistence (pickle). A ZODB database has a single root object (normally a dictionary), which is the only object directly made accessible by the database. All other objects stored in the database are reached through the root object. Objects referenced by an object stored in the database are automatically stored in the database as well.
ZODB supports concurrent transactions using
MVCC and tracks changes to objects on a per-object basis. Only changed objects are committed. Transactions are non-destructive by default and can be reverted.
Example
For example, say we have a car described using 3 classes
Car
,
Wheel
and
Screw
. In Python, this could be represented the following way:
class Car: ..class Wheel: ..class Screw: ..
myCar = Car()
myCar.wheel1 = Wheel()
myCar.wheel2 = Wheel()
for wheel in (myCar.wheel1, myCar.wheel2):
wheel.screws = crew(), Screw()
A crew is a body or a class of people who work at a common activity, generally in a structured or hierarchical organization. A location in which a crew works is called a crewyard or a workyard. The word has nautical resonances: the tasks i