Le 29/09/2012 19:09, Carlos Daniel Ruvalcaba Valenzuela a écrit :
When autoloading was first implemented there was a discussion on how
to do it, if I recall correctly, the reason to use
templatetools/jinja_filters.py is to not pollute the lib directory and
to have separate files for each template type so that genshi will not
import jinja stuff which does not support, thus in theory you can have
templatetools/genshi_filters.py and templatetools/jinja_filters.py at
the same time, this however, is not supported right now as Genshi,
Mako and Jinja have very different ways of handling this stuff
(special filter functions vs plain functions).
ok, I understand.
This could work for both solutions : templatetools/jinja_filters.py with
mandatory __all__ containing the filters' list and templatetools.py
contianing a jinja_filters dict...
# Try to load custom filters module under
app_package.lib.templatetools
try:
filter_package = self.package.__name__ + ".lib.templatetools"
autoload_lib = __import__(filter_package, {}, {},
['jinja_filters'])
try:
filters_list = autoload_lib.jinja_filters.__all__
autoload_filters = dict([(k,
autoload_lib.jinja_filters.__dict__[k]) for k in filters_list])
except AttributeError:
autoload_filters = autoload_lib.jinja_filters
except (ImportError, AttributeError):
autoload_filters = {}
--
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.