$ easy_install theengine
$ paster make-config theengine test.ini
$ paster setup-app test.ini
$ emacs extra_templates/base.mako
$ emacs extra_files/base.css
$ paster serve test.ini
For the templates part, this is really easy. In environment.py, one
can do:
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
static_files=os.path.join(root, 'public'),
templates=[os.path.join(global_conf["here"],
"extra_templates"),
os.path.join(root, 'templates'),])
and `render("foo.mako")` will look for the files in roughly this
order:
%(here)s/extra_template/
/path/to/the/egg/theengine/templates/
The cascading lookup is not only for `foo.mako`, it's for all included
or inherited files. This is perfect.
First question: is it possible to include directories in the templates
path list from the .ini without doing the manual parsing in
environment.py?
Second question: the cascading templates path list is perfect and I'd
like to do the same with the static files; the css and images could
easily be changed by the user. Unfortunately, passing a list to
`static_files` won't work. Is there a way to have cascading static
files? There must be one because Pylons supply it's own images and
css for the error pages.
--
Yannick Gingras
> Unfortunately, passing a list to `static_files` won't work. Is
> there a way to have cascading static files?
Thanks to Chairos on #pylons, on just have to hack middleware.py:
static_apps = [StaticURLParser(path)
for path in config['pylons.paths']['static_files']]
app = Cascade(static_apps + [javascripts_app, app])
--
Yannick Gingras
--
Ches Martin
On Oct 8, 3:50 pm, Yannick Gingras <yging...@ygingras.net> wrote:
> Thanks for sharing this stuff, Yannick. One of those things I knew I
> was going to need at some point. It *would* be nice if some of this
> was doable from the .ini. At any rate, sounds like a good start for a
> cookbook entry on a "skinning" setup :-)
Well, once you reach that point it's trivial to add .ini lookup. My
.ini looks like:
[app:main]
extra_templates = %(here)s/extra_templates
extra_statics = %(here)s/extra_statics
...
environment.py has
paths = dict(root=root,
controllers=os.path.join(root, 'controllers'),
static_files=[app_conf["extra_statics"],
os.path.join(root, 'public')],
templates=[app_conf["extra_templates"],
os.path.join(root, 'templates'),])
and middleware.py has
# Static files
javascripts_app = StaticJavascripts()
static_apps = [StaticURLParser(path)
for path in config['pylons.paths']['static_files']]
app = Cascade(static_apps + [javascripts_app, app])
return app
--
Yannick Gingras