Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
ZEO
Commits
4410e38c
Commit
4410e38c
authored
Mar 25, 1997
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed to make all persistent objects transactional.
parent
adc281ba
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
229 additions
and
93 deletions
+229
-93
src/Persistence/cPersistence.c
src/Persistence/cPersistence.c
+66
-30
src/ZODB/Persistence.py
src/ZODB/Persistence.py
+31
-3
src/ZODB/cPersistence.c
src/ZODB/cPersistence.c
+66
-30
src/persistent/cPersistence.c
src/persistent/cPersistence.c
+66
-30
No files found.
src/Persistence/cPersistence.c
View file @
4410e38c
/*
$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $
$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $
C Persistence Module
...
...
@@ -56,7 +56,7 @@
*****************************************************************************/
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $"
;
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $"
;
#include <time.h>
#include "cPersistence.h"
...
...
@@ -218,6 +218,64 @@ Per___changed__(self, args)
return
PyInt_FromLong
(
self
->
state
==
CHANGED_STATE
);
}
static
PyObject
*
T___changed__
(
cPersistentObject
*
self
,
PyObject
*
args
)
{
static
PyObject
*
builtins
=
0
,
*
get_transaction
=
0
,
*
py_register
=
0
;
PyObject
*
o
,
*
T
;
if
(
PyArg_Parse
(
args
,
"O"
,
&
o
))
{
int
t
;
t
=
PyObject_IsTrue
(
o
);
if
(
t
&&
self
->
state
!=
cPersistent_CHANGED_STATE
&&
self
->
jar
)
{
UNLESS
(
get_transaction
)
{
UNLESS
(
builtins
)
{
UNLESS
(
T
=
PyImport_ImportModule
(
"__main__"
))
return
NULL
;
ASSIGN
(
T
,
PyObject_GetAttrString
(
T
,
"__builtins__"
));
UNLESS
(
T
)
return
NULL
;
UNLESS
(
py_register
=
PyString_FromString
(
"register"
))
goto
err
;
builtins
=
T
;
}
UNLESS
(
get_transaction
=
PyObject_GetAttrString
(
builtins
,
"get_transaction"
))
PyErr_Clear
();
}
if
(
get_transaction
)
{
UNLESS
(
T
=
PyObject_CallObject
(
get_transaction
,
NULL
))
return
NULL
;
UNLESS_ASSIGN
(
T
,
PyObject_GetAttr
(
T
,
py_register
))
return
NULL
;
UNLESS
(
o
=
PyTuple_New
(
1
))
goto
err
;
Py_INCREF
(
self
);
PyTuple_SET_ITEM
(
o
,
0
,(
PyObject
*
)
self
);
ASSIGN
(
o
,
PyObject_CallObject
(
T
,
o
));
Py_DECREF
(
T
);
UNLESS
(
o
)
return
NULL
;
Py_DECREF
(
o
);
}
}
if
(
self
->
state
!=
cPersistent_GHOST_STATE
)
self
->
state
=
t
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
{
PyErr_Clear
();
UNLESS
(
PyArg_Parse
(
args
,
""
))
return
NULL
;
return
PyInt_FromLong
(
self
->
state
==
cPersistent_CHANGED_STATE
);
}
err:
Py_DECREF
(
T
);
return
NULL
;
}
static
char
Per___save____doc__
[]
=
"__save__() -- Update the object in a persistent database."
;
...
...
@@ -297,13 +355,7 @@ Per__p___reinit__(cPersistentObject *self, PyObject *args)
if
((
self
->
oid
==
oid
||
PyObject_Compare
(
self
->
oid
,
oid
)
==
0
)
&&
self
->
state
==
cPersistent_UPTODATE_STATE
)
{
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
{
printf
(
"Could not get __dict__ of a %s,
\n
"
,
self
->
ob_type
->
tp_name
);
PyObject_Print
(
self
,
stdout
,
0
);
printf
(
"
\n\n
"
);
return
NULL
;
}
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
return
NULL
;
ASSIGN
(
INSTANCE_DICT
(
self
),
args
);
self
->
state
=
GHOST_STATE
;
}
...
...
@@ -425,7 +477,7 @@ err:
static
struct
PyMethodDef
Per_methods
[]
=
{
{
"__changed__"
,
(
PyCFunction
)
Per
___changed__
,
0
,
Per___changed____doc__
},
{
"__changed__"
,
(
PyCFunction
)
T
___changed__
,
0
,
Per___changed____doc__
},
{
"__save__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___save____doc__
},
{
"__inform_commit__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___inform_commit____doc__
},
{
"__inform_abort__"
,
(
PyCFunction
)
Per___inform_abort__
,
0
,
Per___inform_abort____doc__
},
...
...
@@ -448,8 +500,6 @@ Per_dealloc(self)
{
Py_XDECREF
(
self
->
oid
);
Py_XDECREF
(
self
->
jar
);
Py_XDECREF
(
self
->
rtime
);
Py_XDECREF
(
self
->
atime
);
PyMem_DEL
(
self
);
}
...
...
@@ -533,17 +583,6 @@ Per_getattr(cPersistentObject *self, PyObject *oname, char *name)
return
Py_None
;
}
break
;
case
'r'
:
if
(
strcmp
(
n
,
"ead_time"
)
==
0
)
{
if
(
self
->
rtime
)
{
Py_INCREF
(
self
->
rtime
);
return
self
->
rtime
;
}
else
return
PyFloat_FromDouble
(
0
.
0
);
}
}
}
if
(
!
(
*
name
++==
'_'
&&
*
name
++==
'_'
&&
strcmp
(
name
,
"dict__"
)
==
0
))
...
...
@@ -615,12 +654,6 @@ Per_setattro(cPersistentObject *self, PyObject *oname, PyObject *v)
self
->
state
=
PyObject_IsTrue
(
v
);
return
0
;
}
if
(
strcmp
(
name
+
3
,
"read_time"
)
==
0
)
{
ASSIGN
(
self
->
rtime
,
v
);
Py_INCREF
(
self
->
rtime
);
return
0
;
}
}
else
{
...
...
@@ -727,7 +760,7 @@ void
initcPersistence
()
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
6
$"
;
char
*
rev
=
"$Revision: 1.
7
$"
;
PATimeType
.
ob_type
=&
PyType_Type
;
...
...
@@ -754,6 +787,9 @@ initcPersistence()
/****************************************************************************
$Log: cPersistence.c,v $
Revision 1.7 1997/03/25 20:43:21 jim
Changed to make all persistent objects transactional.
Revision 1.6 1997/03/20 20:58:25 jim
Fixed bug in reinit.
...
...
src/ZODB/Persistence.py
View file @
4410e38c
...
...
@@ -4,7 +4,7 @@
__doc__
=
'''Python implementation of persistent base types
$Id: Persistence.py,v 1.
4 1997/03/14 16:19:55
jim Exp $'''
$Id: Persistence.py,v 1.
5 1997/03/25 20:42:42
jim Exp $'''
# Copyright
#
# Copyright 1996 Digital Creations, L.C., 910 Princess Anne
...
...
@@ -60,6 +60,9 @@ $Id: Persistence.py,v 1.4 1997/03/14 16:19:55 jim Exp $'''
# (540) 371-6909
#
# $Log: Persistence.py,v $
# Revision 1.5 1997/03/25 20:42:42 jim
# Changed to make all persistent objects transactional.
#
# Revision 1.4 1997/03/14 16:19:55 jim
# Changed so no longer save on del.
# Added check in __save__ so that we don't save if we have decided that
...
...
@@ -76,7 +79,7 @@ $Id: Persistence.py,v 1.4 1997/03/14 16:19:55 jim Exp $'''
#
#
#
__version__
=
'$Revision: 1.
4
$'
[
11
:
-
2
]
__version__
=
'$Revision: 1.
5
$'
[
11
:
-
2
]
class
Persistent
:
"""
\
...
...
@@ -210,7 +213,32 @@ class Persistent:
else
:
return
self
.
_p_changed
try
:
from
cPersistence
import
Persistent
# The following was copied from the SingleThreadedTransaction module:
#
# Base class for all transactional objects
# Transactional objects, like persistent objects track
# changes in state. Unlike persistent objects, transactional
# objects work in conjunction with a transaction manager to manage
# saving state and recovering from errors.
#
def
__changed__
(
self
,
v
=
None
):
if
v
and
not
self
.
_p_changed
and
self
.
_p_jar
is
not
None
:
try
:
get_transaction
().
register
(
self
)
except
:
pass
return
Persistence
.
Persistent
.
__changed__
(
self
,
v
)
def
__inform_commit__
(
self
,
transaction
,
start_time
):
self
.
__save__
()
def
__inform_abort__
(
self
,
transaction
,
start_time
):
try
:
self
.
_p_jar
.
oops
(
self
,
start_time
)
except
:
pass
try
:
import
cPersistence
from
cPersistence
import
Persistent
except
:
pass
class
PersistentMapping
(
Persistent
):
...
...
src/ZODB/cPersistence.c
View file @
4410e38c
/*
$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $
$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $
C Persistence Module
...
...
@@ -56,7 +56,7 @@
*****************************************************************************/
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $"
;
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $"
;
#include <time.h>
#include "cPersistence.h"
...
...
@@ -218,6 +218,64 @@ Per___changed__(self, args)
return
PyInt_FromLong
(
self
->
state
==
CHANGED_STATE
);
}
static
PyObject
*
T___changed__
(
cPersistentObject
*
self
,
PyObject
*
args
)
{
static
PyObject
*
builtins
=
0
,
*
get_transaction
=
0
,
*
py_register
=
0
;
PyObject
*
o
,
*
T
;
if
(
PyArg_Parse
(
args
,
"O"
,
&
o
))
{
int
t
;
t
=
PyObject_IsTrue
(
o
);
if
(
t
&&
self
->
state
!=
cPersistent_CHANGED_STATE
&&
self
->
jar
)
{
UNLESS
(
get_transaction
)
{
UNLESS
(
builtins
)
{
UNLESS
(
T
=
PyImport_ImportModule
(
"__main__"
))
return
NULL
;
ASSIGN
(
T
,
PyObject_GetAttrString
(
T
,
"__builtins__"
));
UNLESS
(
T
)
return
NULL
;
UNLESS
(
py_register
=
PyString_FromString
(
"register"
))
goto
err
;
builtins
=
T
;
}
UNLESS
(
get_transaction
=
PyObject_GetAttrString
(
builtins
,
"get_transaction"
))
PyErr_Clear
();
}
if
(
get_transaction
)
{
UNLESS
(
T
=
PyObject_CallObject
(
get_transaction
,
NULL
))
return
NULL
;
UNLESS_ASSIGN
(
T
,
PyObject_GetAttr
(
T
,
py_register
))
return
NULL
;
UNLESS
(
o
=
PyTuple_New
(
1
))
goto
err
;
Py_INCREF
(
self
);
PyTuple_SET_ITEM
(
o
,
0
,(
PyObject
*
)
self
);
ASSIGN
(
o
,
PyObject_CallObject
(
T
,
o
));
Py_DECREF
(
T
);
UNLESS
(
o
)
return
NULL
;
Py_DECREF
(
o
);
}
}
if
(
self
->
state
!=
cPersistent_GHOST_STATE
)
self
->
state
=
t
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
{
PyErr_Clear
();
UNLESS
(
PyArg_Parse
(
args
,
""
))
return
NULL
;
return
PyInt_FromLong
(
self
->
state
==
cPersistent_CHANGED_STATE
);
}
err:
Py_DECREF
(
T
);
return
NULL
;
}
static
char
Per___save____doc__
[]
=
"__save__() -- Update the object in a persistent database."
;
...
...
@@ -297,13 +355,7 @@ Per__p___reinit__(cPersistentObject *self, PyObject *args)
if
((
self
->
oid
==
oid
||
PyObject_Compare
(
self
->
oid
,
oid
)
==
0
)
&&
self
->
state
==
cPersistent_UPTODATE_STATE
)
{
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
{
printf
(
"Could not get __dict__ of a %s,
\n
"
,
self
->
ob_type
->
tp_name
);
PyObject_Print
(
self
,
stdout
,
0
);
printf
(
"
\n\n
"
);
return
NULL
;
}
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
return
NULL
;
ASSIGN
(
INSTANCE_DICT
(
self
),
args
);
self
->
state
=
GHOST_STATE
;
}
...
...
@@ -425,7 +477,7 @@ err:
static
struct
PyMethodDef
Per_methods
[]
=
{
{
"__changed__"
,
(
PyCFunction
)
Per
___changed__
,
0
,
Per___changed____doc__
},
{
"__changed__"
,
(
PyCFunction
)
T
___changed__
,
0
,
Per___changed____doc__
},
{
"__save__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___save____doc__
},
{
"__inform_commit__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___inform_commit____doc__
},
{
"__inform_abort__"
,
(
PyCFunction
)
Per___inform_abort__
,
0
,
Per___inform_abort____doc__
},
...
...
@@ -448,8 +500,6 @@ Per_dealloc(self)
{
Py_XDECREF
(
self
->
oid
);
Py_XDECREF
(
self
->
jar
);
Py_XDECREF
(
self
->
rtime
);
Py_XDECREF
(
self
->
atime
);
PyMem_DEL
(
self
);
}
...
...
@@ -533,17 +583,6 @@ Per_getattr(cPersistentObject *self, PyObject *oname, char *name)
return
Py_None
;
}
break
;
case
'r'
:
if
(
strcmp
(
n
,
"ead_time"
)
==
0
)
{
if
(
self
->
rtime
)
{
Py_INCREF
(
self
->
rtime
);
return
self
->
rtime
;
}
else
return
PyFloat_FromDouble
(
0
.
0
);
}
}
}
if
(
!
(
*
name
++==
'_'
&&
*
name
++==
'_'
&&
strcmp
(
name
,
"dict__"
)
==
0
))
...
...
@@ -615,12 +654,6 @@ Per_setattro(cPersistentObject *self, PyObject *oname, PyObject *v)
self
->
state
=
PyObject_IsTrue
(
v
);
return
0
;
}
if
(
strcmp
(
name
+
3
,
"read_time"
)
==
0
)
{
ASSIGN
(
self
->
rtime
,
v
);
Py_INCREF
(
self
->
rtime
);
return
0
;
}
}
else
{
...
...
@@ -727,7 +760,7 @@ void
initcPersistence
()
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
6
$"
;
char
*
rev
=
"$Revision: 1.
7
$"
;
PATimeType
.
ob_type
=&
PyType_Type
;
...
...
@@ -754,6 +787,9 @@ initcPersistence()
/****************************************************************************
$Log: cPersistence.c,v $
Revision 1.7 1997/03/25 20:43:21 jim
Changed to make all persistent objects transactional.
Revision 1.6 1997/03/20 20:58:25 jim
Fixed bug in reinit.
...
...
src/persistent/cPersistence.c
View file @
4410e38c
/*
$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $
$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $
C Persistence Module
...
...
@@ -56,7 +56,7 @@
*****************************************************************************/
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
6 1997/03/20 20:58:25
jim Exp $"
;
static
char
*
what_string
=
"$Id: cPersistence.c,v 1.
7 1997/03/25 20:43:21
jim Exp $"
;
#include <time.h>
#include "cPersistence.h"
...
...
@@ -218,6 +218,64 @@ Per___changed__(self, args)
return
PyInt_FromLong
(
self
->
state
==
CHANGED_STATE
);
}
static
PyObject
*
T___changed__
(
cPersistentObject
*
self
,
PyObject
*
args
)
{
static
PyObject
*
builtins
=
0
,
*
get_transaction
=
0
,
*
py_register
=
0
;
PyObject
*
o
,
*
T
;
if
(
PyArg_Parse
(
args
,
"O"
,
&
o
))
{
int
t
;
t
=
PyObject_IsTrue
(
o
);
if
(
t
&&
self
->
state
!=
cPersistent_CHANGED_STATE
&&
self
->
jar
)
{
UNLESS
(
get_transaction
)
{
UNLESS
(
builtins
)
{
UNLESS
(
T
=
PyImport_ImportModule
(
"__main__"
))
return
NULL
;
ASSIGN
(
T
,
PyObject_GetAttrString
(
T
,
"__builtins__"
));
UNLESS
(
T
)
return
NULL
;
UNLESS
(
py_register
=
PyString_FromString
(
"register"
))
goto
err
;
builtins
=
T
;
}
UNLESS
(
get_transaction
=
PyObject_GetAttrString
(
builtins
,
"get_transaction"
))
PyErr_Clear
();
}
if
(
get_transaction
)
{
UNLESS
(
T
=
PyObject_CallObject
(
get_transaction
,
NULL
))
return
NULL
;
UNLESS_ASSIGN
(
T
,
PyObject_GetAttr
(
T
,
py_register
))
return
NULL
;
UNLESS
(
o
=
PyTuple_New
(
1
))
goto
err
;
Py_INCREF
(
self
);
PyTuple_SET_ITEM
(
o
,
0
,(
PyObject
*
)
self
);
ASSIGN
(
o
,
PyObject_CallObject
(
T
,
o
));
Py_DECREF
(
T
);
UNLESS
(
o
)
return
NULL
;
Py_DECREF
(
o
);
}
}
if
(
self
->
state
!=
cPersistent_GHOST_STATE
)
self
->
state
=
t
;
Py_INCREF
(
Py_None
);
return
Py_None
;
}
else
{
PyErr_Clear
();
UNLESS
(
PyArg_Parse
(
args
,
""
))
return
NULL
;
return
PyInt_FromLong
(
self
->
state
==
cPersistent_CHANGED_STATE
);
}
err:
Py_DECREF
(
T
);
return
NULL
;
}
static
char
Per___save____doc__
[]
=
"__save__() -- Update the object in a persistent database."
;
...
...
@@ -297,13 +355,7 @@ Per__p___reinit__(cPersistentObject *self, PyObject *args)
if
((
self
->
oid
==
oid
||
PyObject_Compare
(
self
->
oid
,
oid
)
==
0
)
&&
self
->
state
==
cPersistent_UPTODATE_STATE
)
{
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
{
printf
(
"Could not get __dict__ of a %s,
\n
"
,
self
->
ob_type
->
tp_name
);
PyObject_Print
(
self
,
stdout
,
0
);
printf
(
"
\n\n
"
);
return
NULL
;
}
UNLESS
(
args
=
PyObject_GetAttr
(
copy
,
py___dict__
))
return
NULL
;
ASSIGN
(
INSTANCE_DICT
(
self
),
args
);
self
->
state
=
GHOST_STATE
;
}
...
...
@@ -425,7 +477,7 @@ err:
static
struct
PyMethodDef
Per_methods
[]
=
{
{
"__changed__"
,
(
PyCFunction
)
Per
___changed__
,
0
,
Per___changed____doc__
},
{
"__changed__"
,
(
PyCFunction
)
T
___changed__
,
0
,
Per___changed____doc__
},
{
"__save__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___save____doc__
},
{
"__inform_commit__"
,
(
PyCFunction
)
Per___save__
,
0
,
Per___inform_commit____doc__
},
{
"__inform_abort__"
,
(
PyCFunction
)
Per___inform_abort__
,
0
,
Per___inform_abort____doc__
},
...
...
@@ -448,8 +500,6 @@ Per_dealloc(self)
{
Py_XDECREF
(
self
->
oid
);
Py_XDECREF
(
self
->
jar
);
Py_XDECREF
(
self
->
rtime
);
Py_XDECREF
(
self
->
atime
);
PyMem_DEL
(
self
);
}
...
...
@@ -533,17 +583,6 @@ Per_getattr(cPersistentObject *self, PyObject *oname, char *name)
return
Py_None
;
}
break
;
case
'r'
:
if
(
strcmp
(
n
,
"ead_time"
)
==
0
)
{
if
(
self
->
rtime
)
{
Py_INCREF
(
self
->
rtime
);
return
self
->
rtime
;
}
else
return
PyFloat_FromDouble
(
0
.
0
);
}
}
}
if
(
!
(
*
name
++==
'_'
&&
*
name
++==
'_'
&&
strcmp
(
name
,
"dict__"
)
==
0
))
...
...
@@ -615,12 +654,6 @@ Per_setattro(cPersistentObject *self, PyObject *oname, PyObject *v)
self
->
state
=
PyObject_IsTrue
(
v
);
return
0
;
}
if
(
strcmp
(
name
+
3
,
"read_time"
)
==
0
)
{
ASSIGN
(
self
->
rtime
,
v
);
Py_INCREF
(
self
->
rtime
);
return
0
;
}
}
else
{
...
...
@@ -727,7 +760,7 @@ void
initcPersistence
()
{
PyObject
*
m
,
*
d
;
char
*
rev
=
"$Revision: 1.
6
$"
;
char
*
rev
=
"$Revision: 1.
7
$"
;
PATimeType
.
ob_type
=&
PyType_Type
;
...
...
@@ -754,6 +787,9 @@ initcPersistence()
/****************************************************************************
$Log: cPersistence.c,v $
Revision 1.7 1997/03/25 20:43:21 jim
Changed to make all persistent objects transactional.
Revision 1.6 1997/03/20 20:58:25 jim
Fixed bug in reinit.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment