#2192 is probably related to this, and it should be noted that
templating.mako.compiled_templates_dir only works with
use_dotted_templatenames as False as well.
--
Ticket URL: <http://trac.turbogears.org/ticket/2395>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
I assume you are actually referring to Mako's creation of .py (and .pyc)
files from .mak files. If so, this is caused by not letting the Mako
template loader actually load the file and reading the file and passing a
string instead.
If you are referring to something else, let me know.
Also there is a bug in Mako that is related to this:
http://www.makotemplates.org/trac/ticket/128 which I have also provided a
patch for.
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:3>
Ok, so my patch breaks custom `templating.mako.compiled_templates_dir`
when used in conjunction with 'use_dotted_templatenames', since passing an
absolute path to the mako Template(module_directory=) will still put them
in myproject/templates/
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
Ok, I pushed out a couple of small tweaks, and everything seems to be
working fine (aside from lambacck's windows-specific mako issue mentioned
above). Closing...
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:6>
* owner: => lmacken
* status: new => assigned
Comment:
I just committed pushed this patch, which is similar to yours:
http://bitbucket.org/turbogears/tg-dev/changeset/020db0b5043e/
All of the test suite passes, and this doesn't require any Mako changes.
Can you please test and verify that it still works for you in windows?
Thanks!
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:4>
* cc: percious (added)
* status: closed => reopened
* resolution: fixed =>
Comment:
Reopening, since I'm not 100% satisfied with how this works by default.
Right now out of the box (with this patch) `use_dotted_templatenames` is
enabled and Mako stores your compiled bytecode in
`myproject/templates/the/full/path/to/myproject/templates/index.pyc`.
This behavior is documented by Mako
(http://www.makotemplates.org/docs/usage.html#usage_file).
`templating.mako.compiled_templates_dir` defaults to your templates
directory, and when `use_dotted_templatenames` is disabled Mako compiles
and stores templates alongside the existing templates.
I don't know if we can easily have the same behavior with and without
dotted templatenames, but I think we could do a better job of docmenting
this and making it easy to change, without polluting the project's
templates directory.
So, how about we add something like this in the default ini?
{{{
{{if mako}}
# The location to store your compiled templates
templating.mako.compiled_templates_dir = %(here)/data/templates
{{endif}}
}}}
This way, we're sharing %(here)/data with Beaker sessions and we're not
touching the projects templates directory.
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:7>
lmacken's comment applies to all Mako template caching and not just dotted
names since we copied the behaviour of attempting to pick a suitable
location from the non-dotted method.
I think that defaulting to explicit location is a good idea in general,
because most users are going to want to have the compiled templates cached
if only to assist with debugging. This means a better experience for new
TG + Mako developers.
With the current code I don't think there is anyway to avoid writing the
templates somewhere to disk (what happens when the process does not have
write permissions?), so we might want to make no caching of templates an
option at some point in the future. We might want to let
"`templating.mako.compiled_templates_dir = None`"
mean "don't cache the templates" or let the option be more explicit and
don't cache the templates to disk unless a valid path is provided (maybe
log a warning if there is a problem with the path).
In TG1, the equivalent of templating.mako.compiled_templates_dir defaulted
to makotemplates (or something similar) in the development.ini but the
line was commented out. If it was commented out then no template modules
were written to disk.
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:8>
Would you like me to submit patches for what is discussed above?
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:9>
Replying to [comment:9 lambacck]:
> Would you like me to submit patches for what is discussed above?
Sure. Sorry, I meant to get this done before the weekend, but but caught
up with other things. If you're willing and able to throw this patch
together, please do so. If not, I can hack it together later this week.
Cheers.
--
Ticket URL: <http://trac.turbogears.org/ticket/2395#comment:10>