Commit 4ebc9555 authored by Shane Hathaway's avatar Shane Hathaway

Merged the Mount-Dev branch into the main trunk.

parent 2ef8c745
......@@ -84,8 +84,8 @@
##############################################################################
"""Database connection support
$Id: Connection.py,v 1.33 2000/05/20 15:54:28 jim Exp $"""
__version__='$Revision: 1.33 $'[11:-2]
$Id: Connection.py,v 1.34 2000/05/24 20:53:34 shane Exp $"""
__version__='$Revision: 1.34 $'[11:-2]
from cPickleCache import PickleCache
from POSException import ConflictError, ExportError
......@@ -115,6 +115,9 @@ class Connection(ExportImport.ExportImport):
_debug_info=()
_opened=None
# Experimental. Other connections can register to be closed
# when we close by putting something here.
def __init__(self, version='', cache_size=400,
cache_deactivate_after=60):
"""Create a new Connection"""
......@@ -232,6 +235,10 @@ class Connection(ExportImport.ExportImport):
def cacheFullSweep(self, dt=0): self._cache.full_sweep(dt)
def cacheMinimize(self, dt=0): self._cache.minimize(dt)
__onCloseCallbacks=()
def onCloseCallback(self, f):
self.__onCloseCallbacks=self.__onCloseCallbacks+(f,)
def close(self):
self._incrgc() # This is a good time to do some GC
db=self._db
......@@ -239,6 +246,14 @@ class Connection(ExportImport.ExportImport):
self._debug_info=()
db._closeConnection(self)
# Call the close callback
for f in self.__onCloseCallbacks:
try: f()
except:
f=getattr(f, 'im_self', f)
LOG('ZODB',ERROR, 'Close callback failed for %s' % f)
self.__onCloseCallbacks=()
def commit(self, object, transaction, _type=type, _st=type('')):
oid=object._p_oid
invalid=self._invalid
......
This diff is collapsed.
......@@ -84,8 +84,8 @@
##############################################################################
'''BoboPOS-defined exceptions
$Id: POSException.py,v 1.4 2000/05/17 19:45:18 jim Exp $'''
__version__='$Revision: 1.4 $'[11:-2]
$Id: POSException.py,v 1.5 2000/05/24 20:53:34 shane Exp $'''
__version__='$Revision: 1.5 $'[11:-2]
class POSError(Exception):
......@@ -129,6 +129,10 @@ class StorageSystemError(StorageError):
"""Panic! Internal storage error!
"""
class MountedStorageError(StorageError):
"""Unable to access mounted storage.
"""
class ExportError(POSError):
"""An export file doesn't have the right format.
"""
......@@ -152,4 +156,3 @@ class InvalidObjectReference(POSError):
o A reference to an object in a different database connection.
"""
......@@ -189,7 +189,16 @@ persistent_id_call(persistent_id *self, PyObject *args, PyObject *kwargs)
if oid is None or object._p_jar is not self:
*/
if (oid != Py_None)
{
UNLESS (jar=PyObject_GetAttr(object, py__p_jar)) PyErr_Clear();
if (jar && jar != Py_None && jar != self->jar)
{
PyErr_SetString(InvalidObjectReference,
"Attempt to store an object from a foreign "
"database connection");
return NULL;
}
}
if (oid == Py_None || jar != self->jar)
{
......@@ -319,7 +328,7 @@ void
initcoptimizations()
{
PyObject *m, *d;
char *rev="$Revision: 1.7 $";
char *rev="$Revision: 1.8 $";
#define make_string(S) if (! (py_ ## S=PyString_FromString(#S))) return
make_string(_p_oid);
......
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