Hello,

I'm testing my new json rendering code for TurboGears and found an
interesting bug.

I got a controller like

    @expose('{{package}}.templates.info')
    @expose('json')
    def environ(self):
        return dict(environment=request.environ)

for those not familiar it's simply setting two routes one for
environ.json and another for environ.html that users the template name
info.

Now the bug is that request.environ is of type
pylons.util.AttribSafeContextObj which overwrites __getattr__ to
return '' on a "not found". My json code has this check

        if hasattr(obj, '__json__'):
            return obj.__json__()

which is giving me the following error
TypeError: 'str' object is not callable

So the question is what's wrong?
a) should AttribSafeContextObj not return the empty string?
b) should I make my code more demanding of the type and add a callable() check?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to