Without the mako.directories setting you may need a forward slash for a relative renderer link, eg
Replace this: @view_config(route_name='home', renderer='templates/ mytemplate.mako') With this: @view_config(route_name='home', renderer='/templates/ mytemplate.mako') I am using the mako.directories config in the development.ini, & as my templates are in sub-folders, I have to prefix those folder paths with a forward-slash... Cheers, Bruce Coble On Dec 19, 8:57 am, "Thijs Engels" <[email protected]> wrote: > First of all, thank you very much for your response. > > In order to locate the 'issue', I did a complete new install (new > virtualenv and easy_install pyramid). After the populate script, I tried > running the example from the scaffold which is using Chameleon. This > works, page is rendering fine, not issues whatsoever. One thing I did > notice is this entry in 'Settings' from the debug toolbar: > > mako.directories [] > > However some checking cleared up that this is added by the toolbar > itself: > > if not 'mako.directories' in config.registry.settings: > config.registry.settings['mako.directories'] = [] > > After simply copying mytemplate.pt to mytemplate.mako in the templates > directory (not sure whether parsing will be fine, but aiming at the > initial exception), the deault views.py is changed to point to the mako > template: > > @view_config(route_name='home', renderer='templates/mytemplate.mako') > > Running this setup leaves us with the same error as indicated before: > > mako.exceptions.TopLevelLookupException: Cant locate template for uri > 'templates/mytemplate.mako' > > As suggested I added mako.directories to the development.ini, however > the exception above remains. But as this already contains the > 'templates' folder I changed the renderer to file name only: > > @view_config(route_name='home', renderer='mytemplate.mako') > > And... success! Would this indeed be considered the recommended > configuration for Mako? > > Thijs > > > > > > > > On Sun, Dec 18, 2011, at 10:25, Mike Orr wrote: > > On Sun, Dec 18, 2011 at 2:37 AM, Thijs Engels <[email protected]> > > wrote: > > > present in the application stanza of your configuration’s ini file: > > > mako.directories = mypackage:templates > > > This is necessary in order to do the normal > > ``renderer="mytemplate.mak")`` > > I learned this the hard way. I think it was present in an earlier > > version of the standard scaffolds, but was removed at some point. At > > least, it's in the Akhet scaffold, and I don't think I would have put > > it there if it hadn't been in the standard scaffolds. > > > > """ > > > 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. > > > """ > > > This means you can use an asset spec instead of a relative path. > > ``renderer="mypackage:templates/mytemplate.mak"`` > > Chameleon uses asset specs; the default scaffold has > > ``renderer="templates/my_template.pt"``, so I assume you can just > > change the extension and create the template, and it should work. > > >http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/ass... > > > > from pyramid.mako_templating import renderer_factory as mako_factory > > > config.add_renderer('.mako', mako_factory) > > > This is built into Pyramid so you don't need to add it. Both .mak and > > .mako are registered for Mako. If you want to use another extension > > like .html, then you have to add this line. > > > > File "C:\Projects\Pyramid\lib\site-packages\pyramid\path.py", line 26, > > > in caller_module > > > module = sys.modules[module_name] > > > KeyError: 'indices_mako' > > > I got something like this when I put in an add_renderer line for .html > > . It wasn't exactly the same error though, and after a couple tries it > > seemed to go away on its own. I think the error was a > > setuptools.require() something, which is related (it's indirectly an > > import). I think I deleted my .pyc files and regenerated the package > > metadata ("python setup.py egg_info") to get rid of any stale files, > > but I can't be sure any of those fixed it. I know I didn't modify > > anything in the Pyramid package. > > > By the way, I'm getting an incompatibility with > > ``mako.strict_undefined = true``. It raises an undefined error in the > > debug toolbar on 'session' if you don't have Beaker sessions set up. > > I'll do some more poking around and file a bug report. > > > -- > > Mike Orr <[email protected]> > > > -- > > You received this message because you are subscribed to the Google Groups > > "pylons-discuss" 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/pylons-discuss?hl=en. -- You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en.
