diff options
author | R. Tyler Ballance <tyler@slide.com> | 2009-06-27 22:48:42 -0700 |
---|---|---|
committer | R. Tyler Ballance <tyler@slide.com> | 2009-06-27 22:48:42 -0700 |
commit | db028c1144a376fdbda171b3f93a996d13c3726b (patch) | |
tree | c0c714db6e5b9f60eafb20ee8bdb1af96beaa019 | |
parent | a97aa33e964cefa6659e5bdf32b7182ad611390a (diff) | |
download | python-cheetah-db028c1144a376fdbda171b3f93a996d13c3726b.tar.gz |
Revert "Implement valorDefault in C"
This reverts commit e570b82844ac94788cbef9c16f431afbaf6fd483.
Backing this out to bring back my previous work with the
Unspecified module
Conflicts:
src/Template.py
-rw-r--r-- | src/c/_template.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/c/_template.c b/src/c/_template.c index 15aff86..146871c 100644 --- a/src/c/_template.c +++ b/src/c/_template.c @@ -9,18 +9,18 @@ extern "C" { #endif +static PyObject *unspecifiedModule = NULL; +static PyObject *unspecified = NULL; + static PyObject *py_valordefault(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *value, *def; + PyObject *value, *def, *res; if (!PyArg_ParseTuple(args, "OO", &value, &def)) return NULL; - if (value == Py_None) { - Py_XINCREF(def); + if (value == unspecified) return def; - } - Py_XINCREF(value); return value; } @@ -36,6 +36,12 @@ PyMODINIT_FUNC init_template() { PyObject *module = Py_InitModule3("_template", _template_methods, _template_doc); + unspecifiedModule = PyImport_ImportModule("Cheetah.Unspecified"); + if ( (PyErr_Occurred()) || (!unspecifiedModule) ) + return NULL; + unspecified = PyObject_GetAttrString(unspecifiedModule, "Unspecified"); + if (PyErr_Occurred()) + return NULL; } #ifdef __cplusplus |