[albatross-users] Two questions (client-side production of static pages)
Andy Gimblett
gimbo at ftech.net
Fri Jun 28 01:25:13 EST 2002
Hi there,
First, let me say I've been using Albatross for a little while now to
power my weblog (http://gimbo.org.uk/) and I really like it: it
certainly seems to achieve the stated aim of staying "out of the way"
and letting me get on with what I want to do in a reasonably obvious
manner.
I'm (currently) only using Albatross on the client-side.
Specifically, I'm using its templating capabilities to build static
pages which then get uploaded to my ISP's web server. There are a
couple of things I've had problems with. I've fixed one (sort of),
but the other leaves me stumped.
The first question/point: I want to be able to produce output to a
file, not just stdout (don't want to use redirection as using stdout
for other purposes). Now, I've achieved this by patching ExecuteMixin
and SimpleContext in the following "quick and dirty" manner:
class ExecuteMixin:
'''Manages a template execution context
'''
def __init__(self, filehandle=sys.stdout):
self.__macro_stack = []
self.__trap_stack = []
self.reset_content()
self.outputfilehandle = filehandle
def send_content(self, data):
self.outputfilehandle.write(data)
self.outputfilehandle.flush()
class SimpleContext(NamespaceMixin, ExecuteMixin, ResourceMixin,
TemplateLoaderMixin, StubRecorderMixin,
StubSessionMixin):
def __init__(self, template_path, outputfile=sys.stdout):
import tags
NamespaceMixin.__init__(self)
ExecuteMixin.__init__(self, outputfile)
ResourceMixin.__init__(self)
TemplateLoaderMixin.__init__(self, template_path)
apply(self.register_tagclasses, tags.tags)
self.set_globals(_caller_globals(2))
This works for me, but I was wondering:
- Can anyone think of a better way to achieve this?
- Is this (or a better solution) something that could be folded into
the offical distribution, so I needn't maintain my own fork? :-)
It seems a useful capability to me.
My second question, which I haven't been able to solve, regards
macros. I have pages which are based on a master template, along
these lines:
master.html:
<al-macro name="master">
Stuff stuff stuff
<al-usearg name="body">
Blah blah blah
</al-macro>
somepage.html:
<al-expand name="master">
<al-setarg name="body">
Foo bar, foo bar, foo bar...
</al-setarg>
</al-expand>
Make sense?
Now, what I'd _really_ like is to have a number of templates which are
used to build each page. In particular, a large chunk of master.html
is a sidebar table which is rather large: I'd love to be able to break
that out into a seperate template then bring it in in either
master.html or better yet, somepage.html (then I could have a choice
of sidebars for different pages, all of which use the same master).
My instinct tells me there should be a way to do this but I haven't
been able to find it. Can anyone clue me in?
That's it - thanks again for a cool product.
-Andy
--
Andy Gimblett - Programmer - Frontier Internet Services Limited
Tel: 029 20 820 044 Fax: 029 20 820 035 http://www.frontier.net.uk/
Statements made are at all times subject to Frontier's Terms and
Conditions of Business, which are available upon request.
More information about the Albatross-users
mailing list