#1915: Mako template path issue (TopLevelLookupException: Cant locate template
for
uri '/t2/templates/test.mak')
------------------------+---------------------------------------------------
Reporter: cd34 | Owner: percious
Type: defect | Status: new
Priority: normal | Milestone: 2.0b1
Component: TurboGears | Version: trunk
Severity: normal | Resolution:
Keywords: mako |
------------------------+---------------------------------------------------
Old description:
> When trying to use the mako templating engine, there is a path issue
> dealing with the template location.
>
> While I am sure my solution is not the right one, I don't have the
> expertise to delve into the middleware to know what is being passed in
> order to properly pass or parse the directory path.
>
> When one selects mako in a template and puts the template into the
> templates directory, the following error is raised:
>
> TopLevelLookupException: Cant locate template for uri
> '/t2/templates/test.mak'
>
> From the backtrace, we're able to see the following:
>
> dir '/var/www/tg2/t2/t2/templates'
> self <mako.lookup.TemplateLookup object at 0x8c4cdcc>
> srcfile '/var/www/tg2/t2/t2/templates/t2/templates/test.mak'
> u 't2/templates/test.mak'
> uri '/t2/templates/test.mak'
>
> and if we look closely at dir and u which are joined later:
>
> srcfile = posixpath.normpath(posixpath.join(dir, u))
>
> we can see that it will append dir + u and end up with
>
> /var/www/tg2/t2/t2/templates/t2/templates/test.mak
>
> which will raise an exception.
>
> in the file, lib/python2.5/site-
> packages/Mako-0.2.0-py2.5.egg/mako/lookup.py
>
> replacing line 66 which contains
>
> u = re.sub(r'^\/+', '', uri)
>
> with
>
> u = re.sub(r'^\/+.*\/.*\/', '', uri)
>
> fixes the problem, however, I'm reasonably sure it is not the correct
> solution.
New description:
When trying to use the mako templating engine, there is a path issue
dealing with the template location.
While I am sure my solution is not the right one, I don't have the
expertise to delve into the middleware to know what is being passed in
order to properly pass or parse the directory path.
When one selects mako in a template and puts the template into the
templates directory, the following error is raised:
TopLevelLookupException: Cant locate template for uri
'/t2/templates/test.mak'
From the backtrace, we're able to see the following:
{{{
dir '/var/www/tg2/t2/t2/templates'
self <mako.lookup.TemplateLookup object at 0x8c4cdcc>
srcfile '/var/www/tg2/t2/t2/templates/t2/templates/test.mak'
u 't2/templates/test.mak'
uri '/t2/templates/test.mak'
}}}
and if we look closely at dir and u which are joined later:
srcfile = posixpath.normpath(posixpath.join(dir, u))
we can see that it will append dir + u and end up with
/var/www/tg2/t2/t2/templates/t2/templates/test.mak
which will raise an exception.
in the file, lib/python2.5/site-
packages/Mako-0.2.0-py2.5.egg/mako/lookup.py
replacing line 66 which contains
{{{
u = re.sub(r'^\/+', '', uri)
with
u = re.sub(r'^\/+.*\/.*\/', '', uri)
}}}
fixes the problem, however, I'm reasonably sure it is not the correct
solution.
--
Ticket URL: <http://trac.turbogears.org/ticket/1915#comment:10>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "TurboGears Tickets" group.
This group is read-only. No posting by normal members allowed.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets?hl=en?hl=en
-~----------~----~----~----~------~----~------~--~---