Skip to content
This repository has been archived by the owner on Mar 8, 2018. It is now read-only.

Commit

Permalink
Revert "Implement valorDefault in C"
Browse files Browse the repository at this point in the history
This reverts commit e570b82.

Backing this out to bring back my previous work with the
Unspecified module

Conflicts:

	src/Template.py

Signed-off-by: James Abbatiello <abbeyj@gmail.com>
  • Loading branch information
R. Tyler Ballance authored and abbeyj committed Jun 28, 2009
1 parent 40f1cc2 commit bc455c8
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/c/_template.c
Expand Up @@ -9,18 +9,18 @@
extern "C" { extern "C" {
#endif #endif


static PyObject *unspecifiedModule = NULL;
static PyObject *unspecified = NULL;

static PyObject *py_valordefault(PyObject *self, PyObject *args, PyObject *kwargs) static PyObject *py_valordefault(PyObject *self, PyObject *args, PyObject *kwargs)
{ {
PyObject *value, *def; PyObject *value, *def, *res;


if (!PyArg_ParseTuple(args, "OO", &value, &def)) if (!PyArg_ParseTuple(args, "OO", &value, &def))
return NULL; return NULL;


if (value == Py_None) { if (value == unspecified)
Py_XINCREF(def);
return def; return def;
}
Py_XINCREF(value);
return value; return value;
} }


Expand All @@ -36,6 +36,12 @@ PyMODINIT_FUNC init_template()
{ {
PyObject *module = Py_InitModule3("_template", _template_methods, PyObject *module = Py_InitModule3("_template", _template_methods,
_template_doc); _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 #ifdef __cplusplus
Expand Down

0 comments on commit bc455c8

Please sign in to comment.