From gnb at itga.com.au Tue Dec 2 16:48:56 2003 From: gnb at itga.com.au (Gregory Bond) Date: Tue, 02 Dec 2003 16:48:56 +1100 Subject: [albatross-users] Should escaping also escape "+"? Message-ID: <200312020548.QAA17374@lightning.itga.com.au> Consider this: import albatross ctx = albatross.SimpleContext('.') ctx.locals.val = 'a+b' albatross.Template(ctx, '', ''' Test ''').to_html(ctx) ctx.flush_content() This returns Test But (in the context of a larger application), when the link is clicked on, ctx.locals.file gets set to "a b". (The real code is a form with many filenames and a "process" link next to each to process the named file.) Should the HTML escaping also escape + characters? And "?" characters? Or am I asking Albatross to protect me from myself (or more accurately from idiot users who put "+" signs in filenames) and I should check for this myself? From neel at mediapulse.com Wed Dec 3 02:02:27 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 2 Dec 2003 10:02:27 -0500 Subject: [albatross-users] Should escaping also escape "+"? Message-ID: In looking at the code, it seems albatross does it's own escaping: def escape(text): text = str(text) text = text.replace('&', '&') text = text.replace('<', '<') text = text.replace('>', '>',) text = text.replace('"', '"') text = text.replace("'", ''') return text Is there a reason not to use urllib.quote or urllib.quote_plus? Or maybe urllib wasn't around at the time and this is just some legacy stuff? >>> import urllib >>> urllib.quote_plus('a+b') 'a%2Bb' >>> urllib.quote_plus('?a+b') '%3Fa%2Bb' >>> urllib.quote_plus('?<>&"\'a+b') '%3F%3C%3E%26%22%27a%2Bb' (btw, if you are naming files like the last, there is a special place in /dev/null reserved for you!) Mike > -----Original Message----- > From: Gregory Bond [mailto:gnb at itga.com.au] > Sent: Tuesday, December 02, 2003 12:49 AM > To: albatross-users > Subject: [albatross-users] Should escaping also escape "+"? > > > Consider this: > > import albatross > ctx = albatross.SimpleContext('.') > ctx.locals.val = 'a+b' > albatross.Template(ctx, '', ''' > Test > ''').to_html(ctx) > ctx.flush_content() > > This returns > Test > But (in the context of a larger application), when the link > is clicked on, > ctx.locals.file gets set to "a b". > > (The real code is a form with many filenames and a "process" > link next to each > to process the named file.) > > Should the HTML escaping also escape + characters? And "?" > characters? Or am > I asking Albatross to protect me from myself (or more > accurately from idiot > users who put "+" signs in filenames) and I should check for > this myself? > > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albat ross-users From gabriel.cooper at mediapulse.com Wed Dec 3 09:28:26 2003 From: gabriel.cooper at mediapulse.com (Gabriel Cooper) Date: Tue, 02 Dec 2003 17:28:26 -0500 Subject: [albatross-users] Albatross Macros and Form Elements Message-ID: <3FCD120A.3030800@mediapulse.com> An HTML attachment was scrubbed... URL: From alb-users at repose.cx Wed Dec 3 09:53:52 2003 From: alb-users at repose.cx (Damien Elmes) Date: Wed, 03 Dec 2003 09:53:52 +1100 Subject: [albatross-users] Albatross Macros and Form Elements In-Reply-To: <3FCD120A.3030800@mediapulse.com> (Gabriel Cooper's message of "Tue, 02 Dec 2003 17:28:26 -0500") References: <3FCD120A.3030800@mediapulse.com> Message-ID: <86d6b6q1a7.fsf@mobile.repose.cx> Gabriel Cooper writes: > I have a macro containing form elements, such as: > > <al-macro name="form_text"> > <input type="text" name="<al-usearg value='name'>"> > </al-macro> > > but if it's just a normal input type it won't populate form information > automatically, so I swapped it to be an al-input: I ran into something like this, if I understand you correctly. I ended up using a set variable prior to evaluating the macro - ie, instead of using the setarg/usearg, I'd set the variable prior to macro evaluation, like: ... An example of code that calls the macro:

Hope this helps and that I've understood your intention correctly. Cheers, -- Damien Elmes From gabriel.cooper at mediapulse.com Thu Dec 4 08:02:02 2003 From: gabriel.cooper at mediapulse.com (Gabriel Cooper) Date: Wed, 03 Dec 2003 16:02:02 -0500 Subject: [albatross-users] Albatross Macros and Form Elements In-Reply-To: <86d6b6q1a7.fsf@mobile.repose.cx> References: <3FCD120A.3030800@mediapulse.com> <86d6b6q1a7.fsf@mobile.repose.cx> Message-ID: <3FCE4F4A.3060307@mediapulse.com> Damien Elmes wrote: >Gabriel Cooper writes: > > > >>I have a macro containing form elements, such as: >> >> >> >> >> >>but if it's just a normal input type it won't populate form information >>automatically, so I swapped it to be an al-input: >> >> > >I ran into something like this, if I understand you correctly. I >ended up using a set variable prior to evaluating the macro > Thanks Damien, you were absolutely correct. I had looked into that but had thought it hadn't worked since a rather obscure error popped up when I tried it. The error turned out to be a documented bug in the version of albatross I'm using, and now it works as expected! Thanks! Before I go I have one extra question: Why doesn't support the nameexpr attribute? E.g. From andrewm at object-craft.com.au Tue Dec 9 09:40:01 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 09 Dec 2003 09:40:01 +1100 Subject: [albatross-users] Albatross Macros and Form Elements In-Reply-To: Message from Gabriel Cooper of "Wed, 03 Dec 2003 16:02:02 CDT." <3FCE4F4A.3060307@mediapulse.com> References: <3FCD120A.3030800@mediapulse.com> <86d6b6q1a7.fsf@mobile.repose.cx> <3FCE4F4A.3060307@mediapulse.com> Message-ID: <20031208224001.B334E3C099@coffee.object-craft.com.au> >Before I go I have one extra question: > >Why doesn't support the nameexpr attribute? > >E.g. > > > > I can't answer for Dave, but I suspect it's because we didn't think of it... care to post a patch? 8-) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sm at smejmoon.lv Tue Dec 9 19:01:15 2003 From: sm at smejmoon.lv (Smejmoon) Date: Tue, 9 Dec 2003 10:01:15 +0200 Subject: [albatross-users] albatross-1.11pre2 does not contain traceback.html Message-ID: <30344588091.20031209100115@smejmoon.lv> in app.py line 287 is: templ = self.load_template('traceback.html') albatross-1.11pre2 does not contain traceback.html is this a bug or did i miss something? G'irts From andrewm at object-craft.com.au Wed Dec 10 00:28:07 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 10 Dec 2003 00:28:07 +1100 Subject: [albatross-users] albatross-1.11pre2 does not contain traceback.html In-Reply-To: Message from Smejmoon of "Tue, 09 Dec 2003 10:01:15 +0200." <30344588091.20031209100115@smejmoon.lv> References: <30344588091.20031209100115@smejmoon.lv> Message-ID: <20031209132807.84B203C099@coffee.object-craft.com.au> >in app.py line 287 is: > templ = self.load_template('traceback.html') > >albatross-1.11pre2 does not contain traceback.html > >is this a bug or did i miss something? That code is wrapped in a try: except: block - the intention is that you can supply a "trackback.html" template to render the exception in a site specific way, but if that fails (because the traceback template is missing, or the traceback template itself has an error), a simple
traceback is generated instead:

        try:
            tmp_ctx = self.create_context()
            tmp_ctx.set_request(req)
            tmp_ctx.locals.python_exc = pyexc
            tmp_ctx.locals.html_exc = htmlexc
            templ = self.load_template('traceback.html')
            templ.to_html(tmp_ctx)
            tmp_ctx.flush_content()
        except:
            req.write_content('
')
            req.write_content(htmlexc)
            req.write_content('\n\n')
            req.write_content(pyexc)
            req.write_content('
') -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Sat Dec 20 06:54:52 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Fri, 19 Dec 2003 14:54:52 -0500 Subject: [albatross-users] Links to related projects Message-ID: Hi, I'm going though and cleaning up my little axe project (http://axe.pseudocode.net), and was wondering if linking to this from the Wiki was a good idea or not; and if so where to link it in. At one time it was talked about having a related links section on the albatross site, but that's up to the object craft guys =). Also, I just may (being XMas and all) go though the TODO list of 11pre2 and knock out those items (esp. since most have my name beside them, lol). Before I start, is 11pre2 the latest or is there a CVS copy I can get at I should work from? Thanks, Mike From neel at mediapulse.com Sat Dec 20 09:40:40 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Fri, 19 Dec 2003 17:40:40 -0500 Subject: [albatross-users] Patch to 1.11pre2 Message-ID: I went though the TODO list with 1.11pre2 and fixed the items I reported: * is confusing. Consider having ctx.req_equals() check for "name.x" if "name" doesn't exist? Should at least mention it in the section of the manual that talks about tags (Michael C. Neel). ---> ctx.req_equals() will return true for input type=image with only the name given * Allow multiple Cookie values to be set (Michael C. Neel). ---> Biggest change made here. The headers mixin now keeps a list of values for each header, which also means get_header returns a list. I opted for get_headers to always return a list as it's consistent, but it could be changed to only return a list on more than one value to remain backwards compatible. Also, this does not work with the httpdapp.py request class, as it keeps headers as a dict internally so doesn't handle duplicate keys. the apacheapp.py was changed to use the add(key, val) method of mod_python to handle the dupes. * ctx.add_session_vars() should create non-existent varaibles with value of None (Michael C. Neel). ---> Does just that now. * Second submission of form will return ctx.req_equals() TRUE for empty fields (Michael C. Neel). ---> I couldn't get this to occur on 1.11pre2, so I consider it fixed =) The patch is against 1.11pre2. All feedback, comments, flames welcome. Thanks, Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: fixes.diff.gz Type: application/x-gzip Size: 1188 bytes Desc: fixes.diff.gz URL: From neel at mediapulse.com Sun Dec 21 02:33:19 2003 From: neel at mediapulse.com (Michael Neel) Date: Sat, 20 Dec 2003 10:33:19 -0500 Subject: [albatross-users] Patch to 1.11pre2 In-Reply-To: Message-ID: <000301c3c70e$98bc9070$0900a8c0@santana> After some thought, I've added a method ctx.add_header. Add_header appends the header to the list, set_header replaces keeping it's same behavior. Otherwise you would have to del_header before every set_header for 95% of headers. This way you just add_header when you want more than one header of the same name. This is a resend of the complete patch again, to be patched against 1.11pre2. Thanks, Mike -------------- next part -------------- A non-text attachment was scrubbed... Name: fixes.diff.gz Type: application/x-gzip Size: 1287 bytes Desc: not available URL: From neel at mediapulse.com Mon Dec 29 13:53:02 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Sun, 28 Dec 2003 21:53:02 -0500 Subject: [albatross-users] Trouble with custom tag Message-ID: <01d401c3cdb6$e00c72c0$c100a8c0@CLAPTON> 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: From gnb at itga.com.au Mon Dec 29 14:46:46 2003 From: gnb at itga.com.au (Gregory Bond) Date: Mon, 29 Dec 2003 14:46:46 +1100 Subject: [albatross-users] Trouble with custom tag In-Reply-To: Your message of Sun, 28 Dec 2003 21:53:02 -0500. Message-ID: <200312290346.OAA16148@lightning.itga.com.au> This is the code I use in one of my custom tag classes, to do the Albatross macro expansion in the "desc" string if needed: if desc.find("= 0: ctx.push_content_trap() Template(ctx, '', desc).to_html(ctx) desc = ctx.pop_content_trap() >From memory, I grabbed this from some of the supplied Albatross tags. From mike at theneels.org Mon Dec 29 13:48:19 2003 From: mike at theneels.org (Mike Neel) Date: Sun, 28 Dec 2003 21:48:19 -0500 Subject: [albatross-users] Trouble with custom tag Message-ID: <01c601c3cdb6$37608440$c100a8c0@CLAPTON> 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: From mike at theneels.org Mon Dec 29 13:50:11 2003 From: mike at theneels.org (Mike Neel) Date: Sun, 28 Dec 2003 21:50:11 -0500 Subject: [albatross-users] Trouble with custom tag Message-ID: <01cf01c3cdb6$7a88e640$c100a8c0@CLAPTON> 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: From neel at mediapulse.com Tue Dec 30 14:38:52 2003 From: neel at mediapulse.com (Michael Neel) Date: Mon, 29 Dec 2003 22:38:52 -0500 Subject: [albatross-users] Trouble with custom tag In-Reply-To: <200312290346.OAA16148@lightning.itga.com.au> Message-ID: <000201c3ce86$72334cd0$0600a8c0@santana> Okay, I'm an idiot, I look right past the push/pop content trap functions. All I needed was is this: def to_html(self, ctx): ctx.push_content_trap() self.flash.to_html(ctx) flash = ctx.pop_content_trap() ctx.push_content_trap() self.noflash.to_html(ctx) noflash = ctx.pop_content_trap() ctx.write_content(flash) Mike -----Original Message----- From: gnb at itga.com.au [mailto:gnb at itga.com.au] Sent: Sunday, December 28, 2003 10:47 PM To: Michael C. Neel Cc: albatross-users at object-craft.com.au Subject: Re: [albatross-users] Trouble with custom tag This is the code I use in one of my custom tag classes, to do the Albatross macro expansion in the "desc" string if needed: if desc.find("= 0: ctx.push_content_trap() Template(ctx, '', desc).to_html(ctx) desc = ctx.pop_content_trap() >From memory, I grabbed this from some of the supplied Albatross tags. From gnb at itga.com.au Wed Dec 31 10:29:53 2003 From: gnb at itga.com.au (Gregory Bond) Date: Wed, 31 Dec 2003 10:29:53 +1100 Subject: [albatross-users] Trouble with custom tag In-Reply-To: Your message of Mon, 29 Dec 2003 22:38:52 -0500. Message-ID: <200312302329.KAA04848@lightning.itga.com.au> I've added some examples to the Wiki for this topic. From sheila at thinkspot.net Wed Dec 31 19:14:48 2003 From: sheila at thinkspot.net (Sheila King) Date: Wed, 31 Dec 2003 00:14:48 -0800 Subject: [albatross-users] pagination with al-for Message-ID: <696013985.1072829688@lsanca1-ar1-4-62-158-245.lsanca1.dsl-verizon.net> Hello, I've set up a portion of my app that displays some log results with pagination (assuming that there are more log entries than the page size I've set). It wasn't too hard to get the prevpage/nextpage links working, so that I can page forward or backward through the entire sequence display. However, I like to be able to jump directly to a particular page. For example, if pagesize is 6, and there are 26 entries, and thus 5 pages... How would I best display a list of page numbers so that I can click directly on a given page number and go to that list of six items? I started to think maybe I need to go to trees for this? Well, hoping for tips or suggestions. Thanks, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org