Commit 37d0cf64 authored by Jeremy Hylton's avatar Jeremy Hylton

Edit docstrings to remove epydoc markup.

parent e7d2b802
This diff is collapsed.
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
############################################################################## ##############################################################################
"""Database objects """Database objects
$Id: DB.py,v 1.68 2004/03/02 15:36:40 jeremy Exp $""" $Id: DB.py,v 1.69 2004/03/04 19:48:04 jeremy Exp $"""
import cPickle, cStringIO, sys import cPickle, cStringIO, sys
from thread import allocate_lock from thread import allocate_lock
...@@ -29,38 +29,27 @@ from zLOG import LOG, ERROR ...@@ -29,38 +29,27 @@ from zLOG import LOG, ERROR
class DB(object): class DB(object):
"""The Object Database """The Object Database
The C{DB} class coordinates the activities of multiple database The DB class coordinates the activities of multiple database
L{Connection} instances. Most of the work is done by the Connection instances. Most of the work is done by the
C{Connections} created via the L{open} method. Connections created via the open method.
The C{DB} instance manages a pool of connections. If a connection The DB instance manages a pool of connections. If a connection is
is closed, it is returned to the pool and its object cache is closed, it is returned to the pool and its object cache is
preserved. A subsequent call to open() will reuse the connection. preserved. A subsequent call to open() will reuse the connection.
There is a limit to the pool size; if all its connections are in There is a limit to the pool size; if all its connections are in
use, calls to open() will block until one of the open connections use, calls to open() will block until one of the open connections
is closed. is closed.
@cvar klass: Class used by L{open} to create database connections The class variable 'klass' is used by open() to create database
@type klass: L{Connection} or a subclass connections. It is set to Connection, but a subclass could override
it to provide a different connection implementation.
@group User Methods: __init__, open, close, undo, pack, setClassFactory
@group Inspection Methods: getName, getSize, objectCount, The database provides a few methods intended for application code
getActivityMonitor, setActivityMonitor -- open, close, undo, pack, setClassFactory -- and a large
@group Connection Pool Methods: getPoolSize, getVersionPoolSize, collection of methods for inspecting the database and its connections'
removeVersionPool, setPoolSize, setVersionPoolSize caches.
@group Transaction Methods: invalidate
@group Other Methods: lastTransaction, connectionDebugInfo
@group Version Methods: modifiedInVersion, abortVersion, commitVersion,
versionEmpty
@group Cache Inspection Methods: cacheDetail, cacheExtremeDetail,
cacheFullSweep, cacheLastGCTime, cacheMinimize, cacheMeanAge,
cacheMeanDeac, cacheMeanDeal, cacheSize, cacheDetailSize,
getCacheSize, getVersionCacheSize, setCacheSize, setVersionCacheSize,
cacheStatistics
@group Deprecated Methods: getCacheDeactivateAfter,
setCacheDeactivateAfter,
getVersionCacheDeactivateAfter, setVersionCacheDeactivateAfter
""" """
klass = Connection # Class to use for connections klass = Connection # Class to use for connections
_activity_monitor = None _activity_monitor = None
...@@ -74,18 +63,17 @@ class DB(object): ...@@ -74,18 +63,17 @@ class DB(object):
): ):
"""Create an object database. """Create an object database.
@param storage: storage for the database, e.g. C{FileStorage} The constructor requires one argument, the storage used by the
@param pool_size: maximum number of open connections database, e.g. FileStorage.
@type pool_size: C{int}
@param cache_size: target size of L{Connection} object cache There are several other optional arguments:
@type cache_size: C{int} pool_size: maximum number of open connections
@param cache_deactivate_after: ignored cache_size: target size of Connection object cache
@param version_pool_size: maximum number of connections (per version) cache_deactivate_after: ignored
@type version_pool_size: C{int} version_pool_size: maximum number of connections (per version)
@param version_cache_size: target size of L{Connection} object version_cache_size: target size of Connection object cache for
cache for version connectios version connections
@type version_cache_size: C{int} version_cache_deactivate_after: ignored
@param version_cache_deactivate_after: ignored
""" """
# Allocate locks: # Allocate locks:
l=allocate_lock() l=allocate_lock()
...@@ -209,7 +197,8 @@ class DB(object): ...@@ -209,7 +197,8 @@ class DB(object):
def cacheDetail(self): def cacheDetail(self):
"""Return information on objects in the various caches """Return information on objects in the various caches
Organized by class.""" Organized by class.
"""
detail = {} detail = {}
def f(con, detail=detail, have_detail=detail.has_key): def f(con, detail=detail, have_detail=detail.has_key):
...@@ -386,7 +375,7 @@ class DB(object): ...@@ -386,7 +375,7 @@ class DB(object):
def open(self, version='', transaction=None, temporary=0, force=None, def open(self, version='', transaction=None, temporary=0, force=None,
waitflag=1, mvcc=True): waitflag=1, mvcc=True):
"""Return a database L{Connection} """Return a database Connection for use by application code.
The optional version argument can be used to specify that a The optional version argument can be used to specify that a
version connection is desired. version connection is desired.
...@@ -396,8 +385,9 @@ class DB(object): ...@@ -396,8 +385,9 @@ class DB(object):
terminated. In addition, connections per transaction are terminated. In addition, connections per transaction are
reused, if possible. reused, if possible.
Note that the connection pool is managed as a stack, to increate the Note that the connection pool is managed as a stack, to
likelihood that the connection's stack will include useful objects. increate the likelihood that the connection's stack will
include useful objects.
""" """
self._a() self._a()
try: try:
...@@ -562,14 +552,16 @@ class DB(object): ...@@ -562,14 +552,16 @@ class DB(object):
The cost of this operation varies by storage, but it is The cost of this operation varies by storage, but it is
usually an expensive operation. usually an expensive operation.
@param t: pack time in seconds since the epoch There are two optional arguments that can be used to set the
@type t: C{float} pack time: t, pack time in seconds since the epcoh, and days,
@param days: days to subtract from C{t} to compute pack time the number of days to substract from t or from the current
@type days: C{int} time if t is not specified.
""" """
if t is None: t=time() if t is None:
t=t-(days*86400) t = time()
try: self._storage.pack(t,referencesf) t -= days * 86400
try:
self._storage.pack(t, referencesf)
except: except:
LOG("ZODB", ERROR, "packing", error=sys.exc_info()) LOG("ZODB", ERROR, "packing", error=sys.exc_info())
raise raise
...@@ -588,14 +580,11 @@ class DB(object): ...@@ -588,14 +580,11 @@ class DB(object):
The database stores objects, but uses Python's standard import The database stores objects, but uses Python's standard import
to load the code for those objects. The class factory is used to load the code for those objects. The class factory is used
by the database serialization layer to find the classes. It by the database serialization layer to find the classes. It
uses L{ZODB.broken.find_global<find_global>} by default. uses ZODB.broken.find_global by default.
This method can be used to override the default class loading This method can be used to override the default class loading
code. See L{ZODB.broken.find_global<find_global>} for details code. See ZODB.broken.find_global for details
about the contract of C{factory}. about the contract of factory.
@param factory: A class factory for unpickling
@type factory: C{function}
""" """
self._classFactory = factory self._classFactory = factory
...@@ -617,21 +606,20 @@ class DB(object): ...@@ -617,21 +606,20 @@ class DB(object):
def cacheStatistics(self): return () # :( def cacheStatistics(self): return () # :(
def undo(self, id, transaction=None): def undo(self, id, transaction=None):
"""Undo a transaction identified by C{id}. """Undo a transaction identified by id.
A transaction can be undone if all of the objects involved in A transaction can be undone if all of the objects involved in
the transaction were not modified subsequently, if any the transaction were not modified subsequently, if any
modifications can be resolved by conflict resolution, or if modifications can be resolved by conflict resolution, or if
subsequent changes resulted in the same object state. subsequent changes resulted in the same object state.
The value of C{id} should be generated by calling C{undoLog} The value of id should be generated by calling undoLog()
or C{undoInfo}. The value of C{id} is not the same as a or undoInfo(). The value of id is not the same as a
transaction id used by other methods; it is unique to C{undo}. transaction id used by other methods; it is unique to undo().
@param id: a storage-specific transaction identifier In addition, a user can pass the optional argument,
@type id: C{string} transaction, which identifies a transaction context to use for
@param transaction: a transaction context to use the undo().
@type transaction: C{Transaction}
""" """
if transaction is None: if transaction is None:
transaction = get_transaction() transaction = get_transaction()
......
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