[svn] fixed "Deferred" implementation for the c context
authorArmin Ronacher <armin.ronacher@active-4.com>
Sat, 21 Apr 2007 08:12:43 +0000 (10:12 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Sat, 21 Apr 2007 08:12:43 +0000 (10:12 +0200)
--HG--
branch : trunk

docs/src/designerdoc.txt
jinja/_native.py
jinja/_speedups.c

index 1d6cf665b9f0b06e33aa827b23aebd82dd43a30e..1173763bc31e2358c7a7407a47b8d053276b151b 100644 (file)
@@ -982,7 +982,7 @@ change.
 
         {% call makelist([1, 2, 3, 4, 5, 6]) -%}
           [[{{ item }}]]
-        {% endcall %}
+        {%- endcall %}
 
     This will then produce this output:
 
index 4abbb5c1154c118abe0ea54b8acb403c487dddb8..6a9cb73f0471aec5c879113174cdb4dbcc59fba7 100644 (file)
@@ -14,6 +14,7 @@
     :license: BSD, see LICENSE for more details.
 """
 from jinja.datastructure import Deferred, Undefined
+from jinja.exceptions import TemplateRuntimeError
 
 
 class BaseContext(object):
index e57ac3d74cf0dd04f267aa3015e76e9c91bef901..108697fb636b87fee3b556706560d73d3cc30ffd 100644 (file)
@@ -21,8 +21,7 @@
 #include <structmember.h>
 
 /* Set by init_constants to real values */
-static PyObject *Undefined, *TemplateRuntimeError, *FilterNotFound;
-static PyTypeObject *DeferredType;
+static PyObject *Undefined, *Deferred, *TemplateRuntimeError;
 
 /**
  * Internal struct used by BaseContext to store the
@@ -61,10 +60,8 @@ init_constants(void)
                return 0;
        }
        Undefined = PyObject_GetAttrString(datastructure, "Undefined");
-       PyObject *deferred = PyObject_GetAttrString(datastructure, "Deferred");
-       DeferredType = deferred->ob_type;
+       Deferred = PyObject_GetAttrString(datastructure, "Deferred");
        TemplateRuntimeError = PyObject_GetAttrString(exceptions, "TemplateRuntimeError");
-       FilterNotFound = PyObject_GetAttrString(exceptions, "FilterNotFound");
        Py_DECREF(datastructure);
        Py_DECREF(exceptions);
        return 1;
@@ -272,10 +269,10 @@ BaseContext_getitem(BaseContext *self, PyObject *item)
                        continue;
                }
                Py_INCREF(result);
-               if (PyObject_TypeCheck(result, DeferredType)) {
+               if (PyObject_IsInstance(result, Deferred)) {
                        PyObject *args = PyTuple_New(2);
-                       if (!args || !PyTuple_SetItem(args, 0, (PyObject*)self) ||
-                           !PyTuple_SetItem(args, 1, item))
+                       if (!args || PyTuple_SetItem(args, 0, (PyObject*)self) ||
+                           PyTuple_SetItem(args, 1, item))
                                return NULL;
 
                        PyObject *resolved = PyObject_CallObject(result, args);