Hi,
On 3/20/11 8:10 PM, Kurt Raschke wrote:
How is Jinja2's Undefined intended to interact with objects that have
attributes which return None (such as from SQLAlchemy, where a NULL in
the database is translated to None)? I would expect, based on the
documentation, to be able to write constructs like {% if obj.field is
defined %} or {{ obj.field|d }}. However, unless I've encountered a
bug, it seems like Jinja2 treats None as a defined value—certainly
counterintuitive!
It's intended, but can be changed. Override the finalize method on the
Jinja2 environment to special case None to become an empty string.
Google should have some examples.
Regards,
Armin
--
You received this message because you are subscribed to the Google Groups
"pocoo-libs" 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/pocoo-libs?hl=en.