Skip to content

Commit

Permalink
fixed mako bug #606 for inheritance and includes
Browse files Browse the repository at this point in the history
  • Loading branch information
blaflamme committed Jun 29, 2012
1 parent 71b4737 commit d4147eb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pyramid/mako_templating.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ def adjust_uri(self, uri, relativeto):
def get_template(self, uri):
"""Fetch a template from the cache, or check the filesystem
for it
In addition to the basic filesystem lookup, this subclass will
use pkg_resource to load a file using the asset
specification syntax.
"""
if '$' in uri:
uri = uri.replace('$', ':')
isabs = os.path.isabs(uri)
if (not isabs) and (':' in uri):
# Windows can't cope with colons in filenames, so we replace the
Expand All @@ -70,7 +72,7 @@ def get_template(self, uri):
return TemplateLookup.get_template(self, uri)


registry_lock = threading.Lock()
registry_lock = threading.Lock()

class MakoRendererFactoryHelper(object):
def __init__(self, settings_prefix=None):
Expand Down Expand Up @@ -143,7 +145,7 @@ def sget(name, default=None):

registry_lock.acquire()
try:
registry.registerUtility(lookup, IMakoLookup,
registry.registerUtility(lookup, IMakoLookup,
name=settings_prefix)
finally:
registry_lock.release()
Expand All @@ -166,15 +168,15 @@ class MakoLookupTemplateRenderer(object):
""" Render a :term:`Mako` template using the template
implied by the ``path`` argument.The ``path`` argument may be a
package-relative path, an absolute path, or a :term:`asset
specification`. If a defname is defined, in the form of
package:path/to/template#defname.mako, a function named ``defname``
specification`. If a defname is defined, in the form of
package:path/to/template#defname.mako, a function named ``defname``
inside the template will then be rendered.
"""
def __init__(self, path, defname, lookup):
self.path = path
self.defname = defname
self.lookup = lookup

def implementation(self):
return self.lookup.get_template(self.path)

Expand Down

0 comments on commit d4147eb

Please sign in to comment.