[Zope-Checkins] CVS: ZODB3/persistent - cPersistence.c:1.75.2.4
Fred L. Drake, Jr.
fred at zope.com
Fri Jan 16 16:16:35 EST 2004
Update of /cvs-repository/ZODB3/persistent
In directory cvs.zope.org:/tmp/cvs-serv20549
Modified Files:
Tag: zope3-zodb3-devel-branch
cPersistence.c
Log Message:
- add _p_invalidate() method to invalidate an object unconditionally;
this is equivalent to _p_deactivate(force=True) from ZODB 4
- add _p_state as read-only access to the current state; no weird
interpretation based on _p_changed needed
- export a constant for the sticky state
=== ZODB3/persistent/cPersistence.c 1.75.2.3 => 1.75.2.4 ===
--- ZODB3/persistent/cPersistence.c:1.75.2.3 Fri Jan 16 12:08:45 2004
+++ ZODB3/persistent/cPersistence.c Fri Jan 16 16:16:35 2004
@@ -219,6 +219,20 @@
return Py_None;
}
+static PyObject *
+Per__p_invalidate(cPersistentObject *self)
+{
+ signed char old_state = self->state;
+
+ if (old_state != cPersistent_GHOST_STATE) {
+ if (Per_set_changed(self, NULL) < 0)
+ return NULL;
+ ghostify(self);
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
#include "pickle/pickle.c"
@@ -254,6 +268,8 @@
"_p_deactivate() -- Deactivate the object"},
{"_p_activate", (PyCFunction)Per__p_activate, METH_NOARGS,
"_p_activate() -- Activate the object"},
+ {"_p_invalidate", (PyCFunction)Per__p_invalidate, METH_NOARGS,
+ "_p_invalidate() -- Invalidate the object"},
{"__getstate__", (PyCFunction)Per__getstate__, METH_NOARGS,
pickle___getstate__doc },
@@ -620,12 +636,19 @@
return v;
}
+static PyObject *
+Per_get_state(cPersistentObject *self)
+{
+ return PyInt_FromLong(self->state);
+}
+
static PyGetSetDef Per_getsets[] = {
{"_p_changed", (getter)Per_get_changed, (setter)Per_set_changed},
{"_p_jar", (getter)Per_get_jar, (setter)Per_set_jar},
{"_p_mtime", (getter)Per_get_mtime},
{"_p_oid", (getter)Per_get_oid, (setter)Per_set_oid},
{"_p_serial", (getter)Per_get_serial, (setter)Per_set_serial},
+ {"_p_state", (getter)Per_get_state},
{NULL}
};
@@ -751,6 +774,9 @@
return;
if (PyModule_AddIntConstant(m, "CHANGED", cPersistent_CHANGED_STATE) < 0)
+ return;
+
+ if (PyModule_AddIntConstant(m, "STICKY", cPersistent_STICKY_STATE) < 0)
return;
py_simple_new = PyObject_GetAttrString(m, "simple_new");
More information about the Zope-Checkins
mailing list