Le 29/09/2012 18:46, Carlos Daniel Ruvalcaba Valenzuela a écrit :
All other jinja filters configuration is done by defining a dict :

base_config.jinja_filters  =  {'my_filter':  my_filter,
'other_filter_function':  other_filter_function}


so having to define a jinja_filters dict in templatetools.py (or
templatetools.__init__.py) does not seem to be a bad idea to me.

Much simpler than the current solution (so I would say more pythonic ;-) )
Is the templatetools directory supposed to contain something else than
jinja_filters.py (AND __init__.py or it doesn't work !) ?
If you define a templatetools inside lib with an __init__.py, when
choosing jinja templates the code will check if there is a
jinja_filters.py module, if there is it will try to import it,
And if you forget the __init__.py file, the code won't import the existing jinja_filters.py... (without any notice)
however, the problem here seems to be that this code pulls also
uneeded stuff, image you import the sys module, that will get pulled
into the filter namespace too.
Yes, that's what I discovered.
The pythonic solution for this (on modules in general), is to define
the special __all__ dictionary, which tells the importer which
elements of the module should import only, but this only works if you
are using the following import form:

from module import *

We cannot do this on the setup code, we have to rely on tools such as
__module__ which does not do that work for us, but we can try to check
for __all__ and do it manually (which is my proposal.
or import a lib.templatetools.py file containg a jinja_filters dict made on the same model as the

base_config.jinja_filters . This is my proposal :-)

Regards,
Carlos Daniel Ruvalcaba Valenzuela


--
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.

Reply via email to