Bad interaction with AppStats module on AppEngine #6

homunq opened this Issue Nov 18, 2010 · 2 comments

2 participants


Using jinja2 as part of the tipfy framework, the provided appstats middleware causes a bad interaction with jinja2, resulting in an UndefinedError from jinja2. See for details.

I believe that this is weakly a bug on both sides. Appstats should catch the error, but jinja2 should not throw it when the undefined variable is not being used for in-template display. Thus, I think that getattr on runtime.Undefined should raise AttributeError, not UndefinedError, if the attribute is pseudo-private (starts with "_"). Here's the temporary patch I'm using starting at line 460 of; please check this patch (Am I using @internalcode correctly? Do you agree with my reasoning?) and use it if appropriate:

__add__ = __radd__ = __mul__ = __rmul__ = __div__ = __rdiv__ = \
__truediv__ = __rtruediv__ = __floordiv__ = __rfloordiv__ = \
__mod__ = __rmod__ = __pos__ = __neg__ = __call__ = \
__getitem__ = __lt__ = __le__ = __gt__ = __ge__ = \
__int__ = __float__ = __complex__ = __pow__ = __rpow__ = \

def __getattr__(self,attr):
    if attr.startswith("_"):
        raise AttributeError
The Pallets Projects member

Undefineds now support attribute errors for special attributes. This closed by 6a3e95d

The Pallets Projects member

Fixed. But only for "__" and I had to adapt a testcase to that changed behavior too. This will be in 2.6 and not in a bugfix release of 2.5 if there is another one.

@miracle2k miracle2k pushed a commit to miracle2k/jinja2 that referenced this issue Jan 25, 2012
@mitsuhiko mitsuhiko Undefineds now support attribute errors for special attributes. This …
…fixes #6
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment