On Apr 3, 2007, at 12:43 AM, tejas wrote:

>
> Hi
>
> I've been trying to use mako with Turbogears, and end up with a 500
> error
>
> I've set the in config/app.cfg
>
> tg.defaultview = "mako"
>
> I'm trying out the 20 minute wiki and adding mako to it. So I have:
>
> @expose(template="wiki20.templates.page")   #1
>    def index(self , pagename="FrontPage"):     #2
>
> And I have a page.mak  (also tried renaming to .html, and no
> extension) file with the mako template in my templates directory. But
> I get the 500 error traceback:
>
> .
> .
> .
>   File "/usr/lib/python2.4/site-packages/Mako-0.1.5-py2.4.egg/mako/
> lookup.py", line 70, in get_template
>     raise exceptions.TopLevelLookupException("Cant locate template for
> uri '%s'" % uri)
> TopLevelLookupException: Cant locate template for uri
> 'wiki20.templates.page'
>
> Anyone know what I'm doing wrong?

AFAIK Mako's buffet plugin requires you to pass it a  
"mako.directories" config option with the search path(s) for your  
templates. However, Turbogears won't pass the engine plugin that  
option unless you apply the following patch:

Index: turbogears/view/base.py
===================================================================
--- turbogears/view/base.py     (revision 2824)
+++ turbogears/view/base.py     (working copy)
@@ -330,6 +330,7 @@
def load_engines():
      config = turbogears.config
      engine_options ={
+        "mako.directories" : config.get("mako.directories", []),
          "genshi.encoding" : config.get("genshi.encoding", "utf-8"),
          "genshi.default_doctype" : config.get 
("genshi.default_doctype", None),
          "kid.encoding" : config.get("kid.encoding", "utf-8"),

A little bit of digression... It would be nice if TG passed all  
options in the config to the plugin engine(s) so they could pick  
their options, however, its not trivial as CP2 config mechanism is  
not trivial either... :( CP3 has a much saner config mechanism so  
this will probably be much easier to do in TG 1.1 which will use CP3.

I'd like to apply that patch to the 1.0 branch but mako is not  
"officially" supported by TG and the 1.0 branch is frozen except for  
bug-fixes so I think it wouldn't be a good idea.

I believe the above patch plus a "mako.directories" entry in your  
config file will do the trick... tell us how it goes.

Alberto

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to