Commit e6c1e00d authored by Jim Fulton's avatar Jim Fulton

alpha1

parent 618a2277
......@@ -48,12 +48,12 @@
__doc__='''Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.2 1998/10/23 21:40:59 jim Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
$Id: PersistentMapping.py,v 1.3 1998/11/11 02:00:56 jim Exp $'''
__version__='$Revision: 1.3 $'[11:-2]
import Persistence
class PersistentMapping(Persistence.Persistent):
class PM(Persistence.Persistent):
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that
......@@ -65,22 +65,36 @@ class PersistentMapping(Persistence.Persistent):
if container is None: container={}
self._container=container
def __delitem__(self, key):
del self._container[key]
try: del self._v_keys
except: pass
self.__changed__(1)
def __getitem__(self, key):
return self._container[key]
def __len__(self): return len(self._container)
def __setitem__(self, key, v):
self._container[key]=v
try: del self._v_keys
except: pass
self.__changed__(1)
def __delitem__(self, key):
del self._container[key]
try: del self._v_keys
except: pass
self.__changed__(1)
def clear(self):
self._container.clear()
self._p_changed=1
if hasattr(self,'_v_keys'): del self._v_keys
def __len__(self): return len(self._container)
def copy(self): return self.__class__(self._container.copy())
def get(self, key, default): return self._container.get(key, default)
def has_key(self,key): return self._container.has_key(key)
def items(self):
return map(lambda k, d=self: (k,d[k]), self.keys())
def keys(self):
try: return self._v_keys
......@@ -91,14 +105,12 @@ class PersistentMapping(Persistence.Persistent):
keys.sort()
return keys
def clear(self):
self._container={}
if hasattr(self,'_v_keys'): del self._v_keys
def update(self, b):
a=self._container
for k, v in b.items(): a[k] = v
self._p_changed=1
def values(self):
return map(lambda k, d=self: d[k], self.keys())
def items(self):
return map(lambda k, d=self: (k,d[k]), self.keys())
def has_key(self,key): return self._container.has_key(key)
PersistentMapping=PM
This diff is collapsed.
/*
$Id: cPersistence.h,v 1.9 1997/12/15 15:55:16 jim Exp $
$Id: cPersistence.h,v 1.10 1998/11/11 02:00:56 jim Exp $
Definitions to facilitate making cPersistent subclasses in C.
Copyright
Copyright 1996 Digital Creations, L.C., 910 Princess Anne
Street, Suite 300, Fredericksburg, Virginia 22401 U.S.A. All
rights reserved. Copyright in this software is owned by DCLC,
unless otherwise indicated. Permission to use, copy and
distribute this software is hereby granted, provided that the
above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear. Note that
any product, process or technology described in this software
may be the subject of other Intellectual Property rights
reserved by Digital Creations, L.C. and are not licensed
hereunder.
Trademarks
Digital Creations & DCLC, are trademarks of Digital Creations, L.C..
All other trademarks are owned by their respective companies.
No Warranty
The software is provided "as is" without warranty of any kind,
either express or implied, including, but not limited to, the
implied warranties of merchantability, fitness for a particular
purpose, or non-infringement. This software could include
technical inaccuracies or typographical errors. Changes are
periodically made to the software; these changes will be
incorporated in new editions of the software. DCLC may make
improvements and/or changes in this software at any time
without notice.
Limitation Of Liability
In no event will DCLC be liable for direct, indirect, special,
incidental, economic, cover, or consequential damages arising
out of the use of or inability to use this software even if
advised of the possibility of such damages. Some states do not
allow the exclusion or limitation of implied warranties or
limitation of liability for incidental or consequential
damages, so the above limitation or exclusion may not apply to
you.
If you have questions regarding this software,
contact:
Digital Creations L.C.
info@digicool.com
(540) 371-6909
$Log: cPersistence.h,v $
Revision 1.9 1997/12/15 15:55:16 jim
Changed persistent object header layout. This will require recompile
of all C Persistent objects.
Revision 1.8 1997/12/10 22:19:24 jim
Added PER_USE macro.
Revision 1.7 1997/07/18 14:15:39 jim
Added PER_DEL so that subclasses can handle deallocation correctly.
Revision 1.6 1997/06/06 19:13:32 jim
Changed/fixed convenience macros.
Revision 1.5 1997/05/19 17:51:20 jim
Added macros to simplify C PO implementation.
Revision 1.4 1997/05/19 13:49:36 jim
Added include of time.h.
Revision 1.3 1997/04/27 09:18:23 jim
Added to the CAPI to support subtypes (like Record) that want to
extend attr functions.
Revision 1.2 1997/04/22 02:40:28 jim
Changed object header layout.
Revision 1.1 1997/04/01 17:15:48 jim
*** empty log message ***
*/
......@@ -96,24 +15,19 @@
#define cPersistent_HEAD PyObject_HEAD \
PyObject *jar; \
int oid; \
time_t atime; \
char oid[8]; \
unsigned short atime; \
signed char state; \
#define cPersistent_GHOST_STATE -1
#define cPersistent_UPTODATE_STATE 0
#define cPersistent_CHANGED_STATE 1
#define cPersistent_STICKY_STATE 2
typedef struct {
cPersistent_HEAD
} cPersistentObject;
typedef struct {
PyObject_HEAD
cPersistentObject *object;
} PATimeobject;
typedef int (*persetattr)(PyObject *, PyObject*, PyObject *, setattrofunc);
typedef PyObject *(*pergetattr)(PyObject *, PyObject*, char *, getattrofunc);
......@@ -121,7 +35,7 @@ typedef struct {
PyMethodChain *methods;
getattrofunc getattro;
setattrofunc setattro;
int (*changed)(PyObject*);
int (*changed)(cPersistentObject*);
int (*setstate)(PyObject*);
pergetattr pergetattro;
persetattr persetattro;
......@@ -129,16 +43,20 @@ typedef struct {
static cPersistenceCAPIstruct *cPersistenceCAPI;
#define PER_USE_OR_RETURN(O,R) { \
if ((O)->state==cPersistent_GHOST_STATE && \
cPersistenceCAPI->setstate((PyObject*)(O)) < 0) \
return (R); \
else if ((O)->state==cPersistent_UPTODATE_STATE) \
(O)->state=cPersistent_STICKY_STATE; \
}
#define PER_USE_OR_RETURN(O,R) \
if(cPersistenceCAPI->setstate((PyObject*)(O)) < 0) return (R)
#define PER_USE(O) (cPersistenceCAPI->setstate((PyObject*)(O)))
#define PER_CHANGED(O) (cPersistenceCAPI->changed((cPersistentObject*)(O)))
#define PER_CHANGED(O) (cPersistenceCAPI->changed((PyObject*)(O)))
#define PER_ALLOW_DEACTIVATION(O) \
((O)->state==cPersistent_STICKY_STATE && \
((O)->state=cPersistent_UPTODATE_STATE))
#define PER_PREVENT_DEACTIVATION(O) ((O)->atime=(time_t)1);
#define PER_ALLOW_DEACTIVATION(O) ((O)->atime=time(NULL));
#define PER_DEL(O) Py_XDECREF((O)->jar)
#endif
......
This diff is collapsed.
......@@ -11,7 +11,7 @@
static char BTree_module_documentation[] =
""
"\n$Id: BTree.c,v 1.16 1998/03/24 15:17:44 jim Exp $"
"\n$Id: BTree.c,v 1.17 1998/11/11 02:00:55 jim Exp $"
;
#define PERSISTENT
......@@ -22,7 +22,7 @@ static char BTree_module_documentation[] =
#include "ExtensionClass.h"
#define PER_USE_OR_RETURN(self, NULL)
#define PER_ALLOW_DEACTIVATION(self)
#define PER_PREVENT_DEACTIVATION(self)
#define PER_DEL(self)
#endif
......@@ -170,7 +170,7 @@ BTreeItems_item_BTree(char kind, int i, BTree *btree)
if(Bucket_Check(d->value))
{
PER_USE_OR_RETURN(d->value, NULL);
PER_USE_OR_RETURN((Bucket*)(d->value), NULL);
switch(kind)
{
case 'k':
......@@ -867,7 +867,7 @@ BTree_grow(BTree *self, int index)
v=d->value;
UNLESS(e=PyObject_CallObject(OBJECT(v->ob_type), NULL)) return -1;
PER_USE_OR_RETURN(v, -1);
PER_USE_OR_RETURN((Bucket*)v, -1);
if(Bucket_Check(v))
{
......@@ -1273,8 +1273,6 @@ bucket_setstate(Bucket *self, PyObject *args)
char *cv;
#endif
PER_PREVENT_DEACTIVATION(self);
UNLESS(PyArg_ParseTuple(args,"O",&r)) goto err;
UNLESS(PyArg_ParseTuple(r,"OO",&keys,&values)) goto err;
......@@ -1452,8 +1450,6 @@ BTree_setstate(BTree *self, PyObject *args)
UNLESS(PyArg_ParseTuple(args,"O",&state)) return NULL;
if((l=PyTuple_Size(state))<0) return NULL;
PER_PREVENT_DEACTIVATION(self);
if(l>self->size)
{
if(self->data)
......@@ -1610,6 +1606,7 @@ Bucket_dealloc(Bucket *self)
DECREF_VALUE(self->data[i].value);
}
free(self->data);
PER_DEL(self);
PyMem_DEL(self);
}
......@@ -1625,6 +1622,8 @@ BTree_dealloc(BTree *self)
Py_DECREF(self->data[i].value);
}
free(self->data);
PER_DEL(self);
PyMem_DEL(self);
}
......@@ -1762,7 +1761,7 @@ initBTree()
#endif
{
PyObject *m, *d;
char *rev="$Revision: 1.16 $";
char *rev="$Revision: 1.17 $";
UNLESS(PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI"))
return;
......@@ -1798,74 +1797,8 @@ initBTree()
PyDict_SetItemString(d, "__version__",
PyString_FromStringAndSize(rev+11,strlen(rev+11)-2));
#include "dcprotect.h"
/* Check for errors */
if (PyErr_Occurred())
Py_FatalError("can't initialize module BTree");
}
/*
PER_USE_OR_RETURN(self, NULL);
PER_ALLOW_DEACTIVATION(self);
*/
/*****************************************************************************
Revision Log:
$Log: BTree.c,v $
Revision 1.16 1998/03/24 15:17:44 jim
Brought reinit/deactivate machinery up to date.
Revision 1.15 1998/02/18 22:19:50 jim
Fixed C inheritence problem. Waaaaaaa.
Revision 1.14 1998/02/05 17:46:17 jim
Added get methods.
Revision 1.13 1998/02/04 21:11:26 jim
Fixed two leaks in bucket values.
Revision 1.12 1997/12/31 17:18:04 jim
Fixed bugs related to deleting items.
Revision 1.11 1997/12/12 23:43:05 jim
Added basicnew support.
Revision 1.10 1997/11/13 20:45:51 jim
Fixed some bad return values.
Revision 1.9 1997/11/13 20:38:35 jim
added dcprotect
Revision 1.8 1997/11/03 15:17:53 jim
Fixed stupid bug in has_key methods.
Revision 1.7 1997/10/30 20:58:43 jim
Upped bucket sizes.
Revision 1.6 1997/10/10 18:21:45 jim
Fixed bug in range queries.
Revision 1.5 1997/10/01 02:47:06 jim
Fixed bug in setstate that allocates too much memory.
Revision 1.4 1997/09/17 17:20:32 jim
Fixed bug in deleting members from BTree.
Revision 1.3 1997/09/12 18:35:45 jim
Fixed bug leading to random core dumps.
Revision 1.2 1997/09/10 17:24:47 jim
*** empty log message ***
Revision 1.1 1997/09/08 18:42:21 jim
initial BTree
$Revision 1.1 1997/02/24 23:25:42 jim
$initial
$
*****************************************************************************/
##############################################################################
#
# Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# o Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the disclaimer that follows.
#
# o Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# o Neither the name of Digital Creations nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS IS*
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
#
# If you have questions regarding this software, contact:
#
# Digital Creations, L.C.
# 910 Princess Ann Street
# Fredericksburge, Virginia 22401
#
# info@digicool.com
#
# (540) 371-6909
#
##############################################################################
"""Implement an bobo_application object that is BoboPOS3 aware
This module provides a wrapper that causes a database connection to be created
and used when bobo publishes a bobo_application object.
"""
__version__='$Revision: 1.1 $'[11:-2]
class BoboApplication:
def __init__(self, db, name, klass= None, klass_args= (),
version_cookie_name=None):
self._stuff = db, name, version_cookie_name
if klass is not None:
conn=db.open()
root=conn.root()
if not root.has_key(name):
root[name]=klass()
get_transaction().commit()
conn.close()
self._klass=klass
# This hack is to overcome a bug in Bobo!
def __getattr__(self, name):
return getattr(self._klass, name)
def __bobo_traverse__(self, REQUEST=None, name=None):
db, aname, version_support = self._stuff
if version_support is not None and REQUEST is not None:
version=REQUEST.get(version_support,'')
else: version=''
conn=db.open(version)
# arrange for the connection to be closed when the request goes away
cleanup=Cleanup()
cleanup.__del__=conn.close
REQUEST[Cleanup]=cleanup
v=conn.root()[aname]
if name is not None:
if hasattr(v,name): return getattr(v,name)
return v[name]
return v
__call__=__bobo_traverse__ # A convenience for command-line use
class Cleanup: pass
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
##############################################################################
#
# Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# o Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the disclaimer that follows.
#
# o Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# o Neither the name of Digital Creations nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS IS*
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
#
# If you have questions regarding this software, contact:
#
# Digital Creations, L.C.
# 910 Princess Ann Street
# Fredericksburge, Virginia 22401
#
# info@digicool.com
#
# (540) 371-6909
#
##############################################################################
'''BoboPOS-defined exceptions
$Id: POSException.py,v 1.1 1998/11/11 02:00:55 jim Exp $'''
__version__='$Revision: 1.1 $'[11:-2]
class POSError(Exception):
"""Persistent object system error
"""
class TransactionError(POSError):
"""An error occured due to normal transaction processing
"""
class ConflictError(TransactionError):
"""Two transactions tried to modify the same object at once
This transaction should be resubmitted.
"""
class VersionError(POSError):
"""An error in handling versions occurred
"""
class VersionCommitError(VersionError):
"""An invalid combination of versions was used in a version commit
"""
class VersionLockError(VersionError, TransactionError):
"""An attempt was made to modify an object that has
been modified in an unsaved version"""
class UndoError(POSError):
"""An attempt was made to undo an undoable transaction.
"""
class StorageError(POSError):
pass
class StorageTransactionError(StorageError):
"""An operation was invoked for an invalid transaction or state
"""
class StorageSystemError(StorageError):
"""Panic! Internal storage error!
"""
......@@ -45,149 +45,114 @@
# (540) 371-6909
#
##############################################################################
__doc__='''Python implementation of a persistent base types
$Id: Persistence.py,v 1.16 1998/10/23 21:40:15 jim Exp $'''
__version__='$Revision: 1.16 $'[11:-2]
try:
from cPersistence import Persistent
except:
class Persistent:
"""\
Persistent object support mix-in class
When a persistent object is loaded from a database, the object's
data is not immediately loaded. Loading of the objects data is
defered until an attempt is made to access an attribute of the
object.
The object also tries to keep track of whether it has changed. It
is easy for this to be done incorrectly. For this reason, methods
of subclasses that change state other than by setting attributes
should: 'self.__changed__(1)' to flag instances as changed.
You must not override the object's '__getattr__' and '__setattr__'
methods. If you override the objects '__getstate__' method, then
you must be careful not to include any attributes with names
starting with '_p_' or '_v_' in the state.
"""
_p_oid=None # A Persistent object-id, unique within a jar
_p_changed=0 # The object state: None=ghost, 0=normal, 1=changed
_p_jar=None # The last jar that this object was stored in.
def _p___init__(self,oid,jar):
"""Post creation initialization
This is *only* used if we have __getinitargs__!
"""
d=self.__dict__
if d:
newstate={}
for key in d.keys():
if key[:3] != '_p_':
newstate[key]=d[key]
del d[key]
if newstate: d['_p_newstate']=newstate
d['_p_oid']=oid
d['_p_jar']=jar
d['_p_changed']=None
def _p_deactivate(self,copy=None):
if copy is None: newstate=None
else: newstate=copy.__dict__
d=self.__dict__
oid=self._p_oid
jar=self._p_jar
d.clear()
if newstate: d['_p_newstate']=newstate
d['_p_oid']=oid
d['_p_jar']=jar
d['_p_changed']=None
_p___reinit=_p_deactivate # Back. Comp.
def __getattr__(self,key):
'Get an item'
if self._p_changed is None and key[:3] != '_p_':
self._p_jar.setstate(self)
if self.__dict__.has_key(key): return self.__dict__[key]
raise AttributeError, key
def __setattr__(self,key,value):
' '
changed=self._p_changed
if changed:
self.__dict__[key]=value
return
k=key[:3]
if k=='_p_' or k=='_v_':
self.__dict__[key]=value
return
jar=self._p_jar
if jar is None:
self.__dict__[key]=value
return
d=self.__dict__
if changed is None:
d['_p_changed']=1
jar.setstate(self)
d[key]=value
try:
get_transaction().register(self)
d['_p_changed']=1
except: pass
def __changed__(self,v=-1):
old=self._p_changed
if v != -1:
if v and not old and self._p_jar is not None:
try: get_transaction().register(self)
'''Python implementation of a persistent base types
$Id: Persistence.py,v 1.17 1998/11/11 02:00:56 jim Exp $'''
__version__='$Revision: 1.17 $'[11:-2]
_marker=[]
class Persistent:
"""\
Persistent object support mix-in class
When a persistent object is loaded from a database, the object's
data is not immediately loaded. Loading of the objects data is
defered until an attempt is made to access an attribute of the
object.
The object also tries to keep track of whether it has changed. It
is easy for this to be done incorrectly. For this reason, methods
of subclasses that change state other than by setting attributes
should: 'self.__changed__(1)' to flag instances as changed.
You must not override the object's '__getattr__' and '__setattr__'
methods. If you override the objects '__getstate__' method, then
you must be careful not to include any attributes with names
starting with '_p_' or '_v_' in the state.
"""
_p_oid=None # A Persistent object-id, unique within a jar
_p_changed=0 # The object state: None=ghost, 0=normal, 1=changed
_p_jar=None # The last jar that this object was stored in.
def _p_deactivate(self):
d=self.__dict__
oid=d['_p_oid']
jar=d['_p_jar']
d.clear()
d['_p_oid']=oid
d['_p_jar']=jar
d['_p_changed']=None
def __getattr__(self,key):
'Get an item'
if self._p_changed is None and key[:3] != '_p_':
self._p_jar.setstate(self)
if self.__dict__.has_key(key): return self.__dict__[key]
raise AttributeError, key
def __setattr__(self,key,value):
' '
changed=self._p_changed
if changed:
self.__dict__[key]=value
return
k=key[:3]
if k=='_p_' or k=='_v_':
if key=='_p_changed':
if changed == value: return
if value:
if changed: return
try:
if self._p_jar and self._p_oid:
get_transaction().register(self)
except: pass
self._p_changed = not not v
return old
def __getstate__(self):
# First, update my state, if necessary:
if self._p_changed is None: self._p_jar.setstate(self)
state={}
d=self.__dict__
for k,v in d.items():
if k[:3] != '_p_' and k[:3] != '_v_': state[k]=v
return state
def __setstate__(self,state):
d=self.__dict__
for k,v in state.items(): d[k]=v
return state
def __save__(self):
'''\
Update the object in a persistent database.
'''
jar=self._p_jar
if jar and self._p_changed: jar.store(self)
def __repr__(self):
' '
return '<%s instance at %s>' % (self.__class__.__name__,
hex(id(self)))
def __inform_commit__(self,T,start_time):
jar=self._p_jar
if jar and self._p_changed: jar.store(self,T)
def __inform_abort__(self,T,start_time):
try: self._p_jar.abort(self,start_time)
except: pass
elif value is None:
if self._p_jar and self._p_oid:
return self._p_deactivate()
return
value=not not value
self.__dict__[key]=value
return
jar=self._p_jar
if jar is None:
self.__dict__[key]=value
return
d=self.__dict__
if changed is None:
d['_p_changed']=1
jar.setstate(self)
d[key]=value
try:
get_transaction().register(self)
d['_p_changed']=1
except: pass
def __changed__(self,v=_marker):
if v is _marker: return not not self._p_changed
self._p_changed = not not v
def __getstate__(self):
# First, update my state, if necessary:
if self._p_changed is None: self._p_jar.setstate(self)
state={}
d=self.__dict__
for k,v in d.items():
if k[:3] != '_p_' and k[:3] != '_v_': state[k]=v
return state
def __setstate__(self,state):
self.__dict__.update(state)
def __repr__(self):
' '
return '<%s instance at %s>' % (self.__class__.__name__,
hex(id(self)))
......@@ -48,12 +48,12 @@
__doc__='''Python implementation of persistent base types
$Id: PersistentMapping.py,v 1.2 1998/10/23 21:40:59 jim Exp $'''
__version__='$Revision: 1.2 $'[11:-2]
$Id: PersistentMapping.py,v 1.3 1998/11/11 02:00:56 jim Exp $'''
__version__='$Revision: 1.3 $'[11:-2]
import Persistence
class PersistentMapping(Persistence.Persistent):
class PM(Persistence.Persistent):
"""A persistent wrapper for mapping objects.
This class allows wrapping of mapping objects so that
......@@ -65,22 +65,36 @@ class PersistentMapping(Persistence.Persistent):
if container is None: container={}
self._container=container
def __delitem__(self, key):
del self._container[key]
try: del self._v_keys
except: pass
self.__changed__(1)
def __getitem__(self, key):
return self._container[key]
def __len__(self): return len(self._container)
def __setitem__(self, key, v):
self._container[key]=v
try: del self._v_keys
except: pass
self.__changed__(1)
def __delitem__(self, key):
del self._container[key]
try: del self._v_keys
except: pass
self.__changed__(1)
def clear(self):
self._container.clear()
self._p_changed=1
if hasattr(self,'_v_keys'): del self._v_keys
def __len__(self): return len(self._container)
def copy(self): return self.__class__(self._container.copy())
def get(self, key, default): return self._container.get(key, default)
def has_key(self,key): return self._container.has_key(key)
def items(self):
return map(lambda k, d=self: (k,d[k]), self.keys())
def keys(self):
try: return self._v_keys
......@@ -91,14 +105,12 @@ class PersistentMapping(Persistence.Persistent):
keys.sort()
return keys
def clear(self):
self._container={}
if hasattr(self,'_v_keys'): del self._v_keys
def update(self, b):
a=self._container
for k, v in b.items(): a[k] = v
self._p_changed=1
def values(self):
return map(lambda k, d=self: d[k], self.keys())
def items(self):
return map(lambda k, d=self: (k,d[k]), self.keys())
def has_key(self,key): return self._container.has_key(key)
PersistentMapping=PM
......@@ -47,8 +47,8 @@
##############################################################################
__doc__='''PickleJar Object Cache
$Id: PickleCache.py,v 1.4 1998/10/23 21:41:24 jim Exp $'''
__version__='$Revision: 1.4 $'[11:-2]
$Id: PickleCache.py,v 1.5 1998/11/11 02:00:56 jim Exp $'''
__version__='$Revision: 1.5 $'[11:-2]
from sys import getrefcount
......@@ -61,12 +61,14 @@ class PickleCache:
for a in 'keys', 'items', 'values', 'has_key':
setattr(self,a,getattr(self.data,a))
def __getitem__(self, key):
cache=self.data
v=cache[key]
v=self.data[key]
self.incrgc()
return v
def incrgc(self):
# Do cache GC
cache=self.data
n=min(len(cache)/self.cache_size,10)
if n:
l=self.cache_location
......@@ -82,11 +84,13 @@ class PickleCache:
del cache[id]
self.cache_location=l
return v
def __setitem__(self, key, v): self.data[key]=v
def __setitem__(self, key, v):
self.data[key]=v
self.incrgc()
def __delitem__(self, key): del self.data[key]
def __delitem__(self, key):
del self.data[key]
self.incrgc()
def __len__(self): return len(self.data)
......
*shared*
cPersistence cPersistence.c -I../ExtensionClass -I../python
cPickleCache cPickleCache.c -I../ExtensionClass -I../python
#Record Record.c -I../ExtensionClass
cPickleJar ./cPickleJar.c -I../ExtensionClass
iTree ./iTree.c -I../ExtensionClass
intSet ./intSet.c -I/projects/_/ExtensionClass -I/projects/_/cPersistence -I/projects/_/python
BTree ./BTree.c -I/projects/_/ExtensionClass -I/projects/_/cPersistence -I/projects/_/python
IIBTree ./IIBTree.c -I/projects/_/ExtensionClass -I/projects/_/cPersistence -I/projects/_/python
IOBTree ./IOBTree.c -I/projects/_/ExtensionClass -I/projects/_/cPersistence -I/projects/_/python
OIBTree ./OIBTree.c -I/projects/_/ExtensionClass -I/projects/_/cPersistence -I/projects/_/python
#install CacheManager.py
This diff is collapsed.
##############################################################################
#
# Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# o Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the disclaimer that follows.
#
# o Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# o Neither the name of Digital Creations nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS IS*
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
#
# If you have questions regarding this software, contact:
#
# Digital Creations, L.C.
# 910 Princess Ann Street
# Fredericksburge, Virginia 22401
#
# info@digicool.com
#
# (540) 371-6909
#
##############################################################################
from DB import DB
from Persistence import Persistent
from POSException import *
##############################################################################
#
# Copyright (c) 1996-1998, Digital Creations, Fredericksburg, VA, USA.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# o Redistributions of source code must retain the above copyright
# notice, this list of conditions, and the disclaimer that follows.
#
# o Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions, and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
#
# o Neither the name of Digital Creations nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
#
# THIS SOFTWARE IS PROVIDED BY DIGITAL CREATIONS AND CONTRIBUTORS *AS IS*
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DIGITAL
# CREATIONS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
# TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
#
#
# If you have questions regarding this software, contact:
#
# Digital Creations, L.C.
# 910 Princess Ann Street
# Fredericksburge, Virginia 22401
#
# info@digicool.com
#
# (540) 371-6909
#
##############################################################################
"""Thread abstraction module
With this, we can run with or wothout threads.
$Id: bpthread.py,v 1.1 1998/11/11 02:00:56 jim Exp $"""
try:
from thread import *
except:
class allocate_lock:
def acquire(self, *args): return args and 1 or None
def release(self): pass
start_new_thread=apply
"""Install C-based replacements for BoboPOS components.
"""
import cPickleCache, cPersistence
import BoboPOS3, BoboPOS3.Persistence, BoboPOS3.Connection
BoboPOS3.Persistence.Persistent=cPersistence.Persistent
BoboPOS3.Persistent=cPersistence.Persistent
BoboPOS3.Connection.PickleCache=cPickleCache.PickleCache
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -10,7 +10,7 @@
static char intSet_module_documentation[] =
""
"\n$Id: intSet.c,v 1.9 1998/03/24 15:17:34 jim Exp $"
"\n$Id: intSet.c,v 1.10 1998/11/11 02:00:56 jim Exp $"
;
#include <limits.h>
......@@ -225,8 +225,6 @@ intSet___setstate__(intSet *self, PyObject *args)
char *c;
INTSET_DATA_TYPE k;
PER_PREVENT_DEACTIVATION(self);
UNLESS(PyArg_ParseTuple(args,"O",&data)) return PER_RETURN(self, NULL);
UNLESS(c=PyString_AsString(data)) return PER_RETURN(self, NULL);
......@@ -271,7 +269,7 @@ intSet_set_operation(intSet *self, PyObject *other,
o=INTSET(other);
PER_USE_OR_RETURN(self, NULL);
PER_USE_OR_RETURN(other, NULL);
PER_USE_OR_RETURN((intSet*)other, NULL);
od=o->data;
......@@ -537,7 +535,7 @@ void
initintSet()
{
PyObject *m, *d;
char *rev="$Revision: 1.9 $";
char *rev="$Revision: 1.10 $";
UNLESS(ExtensionClassImported) return;
......@@ -575,6 +573,9 @@ initintSet()
Revision Log:
$Log: intSet.c,v $
Revision 1.10 1998/11/11 02:00:56 jim
alpha1
Revision 1.9 1998/03/24 15:17:34 jim
*** empty log message ***
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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