From: Armin Ronacher Date: Mon, 7 Jan 2008 22:26:13 +0000 (+0100) Subject: documented pylons' "strict_c". X-Git-Tag: 2.0rc1~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1986d2c8994c325b5c17b394159c3bfda095659b;p=thirdparty%2Fjinja.git documented pylons' "strict_c". --HG-- branch : trunk --- diff --git a/docs/src/frameworks.txt b/docs/src/frameworks.txt index 96a1cfa8..6511cf7f 100644 --- a/docs/src/frameworks.txt +++ b/docs/src/frameworks.txt @@ -87,6 +87,16 @@ It's meant to be used as replacement for the turbogears package name but Jinja assumes that the name of the template does not include the package path. +.. admonition:: Note + + Special note for pylons users. Jinja will be unable to request attributes + from the special `c` object, unless you set `strict_c` to `True` in the + `environment.py`: + + .. sourcecode:: python + + return pylons.config.Config(tmpl_options, map, paths, strict_c=True) + You can then render the template in the view like this: .. sourcecode:: python diff --git a/jinja/utils.py b/jinja/utils.py index 9444c5cb..acd2018f 100644 --- a/jinja/utils.py +++ b/jinja/utils.py @@ -202,10 +202,7 @@ def get_attribute(obj, name): raise SecurityException('not allowed to access function attributes') r = _getattr(obj, 'jinja_allowed_attributes', None) - # the empty string check is for pylons which returns empty strings on - # it's stacked something foobar object - if r not in (None, '') and name not in r: - print "broken here" + if r is not None and name not in r: raise SecurityException('disallowed attribute accessed') # attribute lookups convert unicode strings to ascii bytestrings.