[albatross-users] Trouble with custom tag

Mike Neel mike at theneels.org
Mon Dec 29 13:48:19 EST 2003


I'm trying to create a custom tag that wraps it's contents in some flash
sniffing javascript.  The contents of the tag need to be executed as
normal, as they could contain other albatross tags, and to do this I'm
calling the Content's to_html method.  The Context class however is set
to write to sys.out, and I need to stop this because I need to alter the
results.  Here is what I'm trying:
 
import albatross, copy
 
class NoFlash(albatross.EmptyTag, albatross.tags.EvalAttribMixin):
    name = "alx-noflash"
 
class Flash(albatross.EnclosingTag, albatross.tags.EvalAttribMixin):
    name = "alx-flash"
 
    def __init__(self, ctx, filename, line_num, attribs):
        albatross.EnclosingTag.__init__(self, ctx, filename, line_num,
attribs)
        self.flash = self.content
        self.noflash = albatross.Content()
        self.noflashseen = 0
 
    def to_html(self, ctx):
        dummy = copy.copy(ctx)
        dummy.send_content = send_content
        self.flash.to_html(dummy)
        self.noflash.to_html(dummy)
 
    def append(self, tag):
        if isinstance(tag, NoFlash) or self.noflashseen:
            self.noflash.append(tag)
            self.noflashseen = 1
        else:
            self.flash.append(tag)
 
def send_content(data):
    assert 0, data
    pass

My assert is not going off.  If I don't do a copy.copy it will go off
correctly, but since it's a reference I just killed the real
send_content, and that's bad.
 
Any thoughts?
 
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.object-craft.com.au/pipermail/albatross-users/attachments/20031228/da9855f4/attachment.html>


More information about the Albatross-users mailing list