[albatross-users] ctx.locals.__page__ for random pages
Dave Cole
djc at object-craft.com.au
Sun Aug 17 20:35:32 EST 2003
> Actually, it would be really nice if run_template() could cope with
> template file paths relative to the current page path. If the
> template name starts with a '/' then it's relative to the
> TemplateLoaderMixin's base_dir, otherwise it's relative to that
> base_dir plus the os.path.dirname() of the page module.
>
> For a page module '/one/two/three/page.py' that would let you do:
>
> def page_display(ctx):
> ctx.runtemplate('page.html')
>
> rather than
>
> def page_display(ctx):
> ctx.runtemplate('one/two/three/page.html')
>
> I think this would only make sense for random apps though, where the
> page modules and template files live together.
It would probably make sense for all types of application.
Currently Albatross only really cares about current directory -
although by passing absolute paths for template and module paths you
can probably eliminate that as well.
To do what you are talking about I think Albatross would need to
develop an internal sense of current page module directory in order to
resolve relative paths.
In order to provide what I think you are asking for it is probably
necessary to introduce one extra path to an Albatross application; the
application root. Once you have specified the root you can make the
page module and template directories relative to that root. In a
sense Albatross currently uses the current working directory as an
implicit application root.
Then any page or template name beginning with / would be relative to
the application root and any not beginning with / would be considered
relative to the directory containing the current page module.
Not sure how hard this would be...
> By the way, is it deliberate that the template name cannot start
> with a '/' at the moment?
Nope.
- Dave
--
http://www.object-craft.com.au
More information about the Albatross-users
mailing list