[albatross-users] load_template vs run_template, macros vs lookups
Andrew McNamara
andrewm at object-craft.com.au
Fri Dec 13 19:10:00 EST 2002
>>I can put <al-macro> definitions in a file, then do a load_template on that
>>file, and the macros are available when I later do a run_template() in a
>>page_display function.
>>
>>But if I put <al-lookup> definitions in this file, then I have to do a
>>run_template()_ in order to make the lookup work.
>>
>>This seems inconsistent. It certainly caused me great confusion!
>
>Oops. I needed the macros registered at load time for something I
>was doing (previously they only registed at run time like lookups) -
>it didn't occur to me that any other tags needed the same treatment.
>I'll see what I can do for the next release (and if the patch is small,
>I'll mail it to the list).
Try this patch (untested):
--- albatross-1.01/albatross/tags.py Thu Sep 5 00:07:10 2002
+++ albatross-1.01-lookup/albatross/tags.py Fri Dec 13 19:08:57 2002
@@ -1026,6 +1026,7 @@
def __init__(self, ctx, filename, line_num, attribs):
EnclosingTag.__init__(self, ctx, filename, line_num, attribs)
self.assert_has_attrib('name')
+ ctx.register_lookup(self.get_attrib('name'), self)
self.item_list = []
def append(self, tag):
@@ -1035,7 +1036,6 @@
EnclosingTag.append(self, tag)
def to_html(self, ctx):
- ctx.register_lookup(self.get_attrib('name'), self)
dict = {}
for item in self.item_list:
dict[item.eval_expr(ctx)] = item
--
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/
More information about the Albatross-users
mailing list