I am having some issues getting Mako templates to work with 1.3a2. However as I am not yet convinced I really know what I am doing I wanted to raise a question here before submitting a bug to Github.
First of all an unclarity: http://docs.pylonsproject.org/projects/pyramid/en/latest/changes.html """ A mako.directories setting is no longer required to use Mako templates Rationale: Mako template renderers can be specified using an absolute asset spec. An entire application can be written with such asset specs, requiring no ordered lookup path. """ Does this mean it is not recommended to add this setting? The narative documentation does mention the adding of this setting here: http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/templates.html#templating-with-mako-templates """ For the above view callable to work, the following setting needs to be present in the application stanza of your configuration’s ini file: mako.directories = mypackage:templates """ At the moment I have not added this setting, but I did add the mako renderer to __init__.py: """ from pyramid.mako_templating import renderer_factory as mako_factory config.add_renderer('.mako', mako_factory) """ With the 1.3 alpha release I noticed that the scaffold is using the config.scan combined with the decorators, so I tried to use my mako templates in line with this setup (__init__.py): """ config.add_route('indices', '/indices/{area}/{date}') """ And in views.py: """ @view_config(route_name='indices', renderer='indices.mako') def indices(request): [...] """ The indices.mako template can be found in the (default) templates directory. Visiting this view results in a mako.exceptions.TopLevelLookupException (Cant locate template for uri 'indices.mako'). My question is what (and in wht file) should be set differently or added to make the renderer find my template file? When I do add the 'mako.directories = baseload:templates' to the ini file there is a different message: """ Traceback (most recent call last): File "C:\Projects\Pyramid\lib\site-packages\pyramid\mako_templating.py", line 154, in __call__ result = template.render_unicode(**system) File "C:\Projects\Pyramid\lib\site-packages\mako\template.py", line 311, in render_unicode as_unicode=True) File "C:\Projects\Pyramid\lib\site-packages\mako\runtime.py", line 661, in _render **_kwargs_for_callable(callable_, data)) File "C:\Projects\Pyramid\lib\site-packages\mako\runtime.py", line 693, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "C:\Projects\Pyramid\lib\site-packages\mako\runtime.py", line 719, in _exec_template callable_(context, *args, **kwargs) File "c:\projects\pyramid\baseload\baseload\templates/indices.mako", line 17, in render_body <link rel="stylesheet" href="${request.static_url('static/css/style.css')}"> File "C:\Projects\Pyramid\lib\site-packages\pyramid\url.py", line 369, in static_url package = caller_package() File "C:\Projects\Pyramid\lib\site-packages\pyramid\path.py", line 52, in caller_package module = caller_module(level+1) File "C:\Projects\Pyramid\lib\site-packages\pyramid\path.py", line 26, in caller_module module = sys.modules[module_name] KeyError: 'indices_mako' """ Thijs -- You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to pylons-discuss@googlegroups.com. To unsubscribe from this group, send email to pylons-discuss+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en.