startling/cytoplasm — Issue #12: mako interpreter can't find template unless you're in the site directory
Author: startling
Created: 2012-03-09 00:07:40+00:00
State: open
Labels: todo

You can see why [here](https://github.com/startling/cytoplasm/blob/master/cytoplasm/defaults.py#L38); basically I have the mako interpreter tell mako where to find templates by having the current directory (`.`) in the TemplateLookup. This fails if you build the site if you're not in the site directory with something like

````
mako.exceptions.TemplateLookupException: Cant locate template for uri u'/_templates/site.mako'
````

This is also why `cytoplasm serve -r` is temporarily broken: it chdirs to the build directory and then builds the site given the absolute path because of how the SimpleHTTPServer works.

This is slightly complicated to fix because the configuration file *doesn't* get the Site object, so it can't look up the full source directory.

There are a couple ways I could fix this:

* pass the Site to each interpreter, which breaks compatibility with old interpreters; people would have to change their configurations. It would also muddle the neat separation of concerns I have going on now, so I'd rather not.

* fix the `cytoplasm serve -r` so it doesn't use SimpleHTTPServer and need to chdir; at best this is a workaround and doesn't fix the underlying problem. (I probably shouldn't be using SimpleHTTPServer anyway but it's standardlib and it works mostly)

* fix the way configuration files work; don't have the defaults at module-level but have a class instead; the class would do some magic in order to import and run the user's configuration file. This would probably require some `eval` or `exec` ugliness.

Any other ideas?