From matt at pollenation.net Sun Jun 1 10:33:33 2003 From: matt at pollenation.net (Matt Goodall) Date: 01 Jun 2003 01:33:33 +0100 Subject: [albatross-users] Simple random mode demo app Message-ID: <1054427612.22691.22.camel@localhost> Hi all, In a previous post I mentioned a simple Albatross test application that I said I would make available. I used it to experiment so it's a bit quick and dirty but it does cover: * Looping over data, changing the CSS style using a . * Paging through a data set. * Using the tree tag to display a categorised view of what's in the test app. * Simple (I mean it!) session use. * Simple macro use. * Custom tags: one that inserts the current time, one that displays its content in a nicely coloured box and one that caches the content to disk for a period of time. It's all very simple - Albatross does all the work. The URL to play with the app is http://mattgoodall.dyndns.org/~matt/albatross/test/ and you can download the source code from http://mattgoodall.dyndns.org/~matt/albatross/test/test.tar.gz. There is a README in the tar.gz although it's very brief. Hopefully, those URLs will be available but my kids do sometimes reboot the machine into Windows to play games ;-). Try again later if necessary. Hope someone finds this useful. Cheers, Matt From matt at pollenation.net Sun Jun 1 18:34:55 2003 From: matt at pollenation.net (Matt Goodall) Date: 01 Jun 2003 09:34:55 +0100 Subject: [albatross-users] Simple random mode demo app In-Reply-To: <1054427612.22691.22.camel@localhost> References: <1054427612.22691.22.camel@localhost> Message-ID: <1054456495.5387.26.camel@localhost> Sorry, the 1st URL should be http://mattgoodall.dyndns.org/~matt/albatross/test/test.py. Cheers, Matt On Sun, 2003-06-01 at 01:33, Matt Goodall wrote: > Hi all, > > In a previous post I mentioned a simple Albatross test application that > I said I would make available. I used it to experiment so it's a bit > quick and dirty but it does cover: > > * Looping over data, changing the CSS style using a . > * Paging through a data set. > * Using the tree tag to display a categorised view of what's in > the test app. > * Simple (I mean it!) session use. > * Simple macro use. > * Custom tags: one that inserts the current time, one that > displays its content in a nicely coloured box and one that > caches the content to disk for a period of time. > > It's all very simple - Albatross does all the work. > > The URL to play with the app is > http://mattgoodall.dyndns.org/~matt/albatross/test/ and you can download > the source code from > http://mattgoodall.dyndns.org/~matt/albatross/test/test.tar.gz. There is > a README in the tar.gz although it's very brief. > > Hopefully, those URLs will be available but my kids do sometimes reboot > the machine into Windows to play games ;-). Try again later if > necessary. > > Hope someone finds this useful. > > Cheers, Matt > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From djc at object-craft.com.au Mon Jun 2 10:30:28 2003 From: djc at object-craft.com.au (Dave Cole) Date: 02 Jun 2003 10:30:28 +1000 Subject: [albatross-users] Re: Debian package of Albatross In-Reply-To: <1053719977.5167.21.camel@kernel> References: <1053106526.25320.4.camel@kernel> <1053719977.5167.21.camel@kernel> Message-ID: >>>>> "Fabian" == Fabian Fagerholm writes: Fabian> On Tue, 2003-05-20 at 04:45, Dave Cole wrote: >> It would be cool to get Albatross into Debian. Fabian> This is a future goal and I have started making the Fabian> appropriate arrangements. However, the package must first Fabian> reach a certain level of quality so the main focus right now Fabian> is on the packaging. Fabian> Currently, I'm having trouble with the generation of the Fabian> Albatross documentation; the HTML docs in particular. The Fabian> provided Makefile in the doc directory uses a tool called Fabian> mkhowto, apparently distributed with Python, to generate the Fabian> docs. I've pulled mkhowto from the Debian Python2.2 packages, Fabian> but I can't seem to make it work. When I first used the Python documentation tools I tried to extract the files that we needed from the distribution. After days of frustration I decided to just use them from the unpacked distribution directory. It would be a big help if there was a Debian package for the cools tools and files in the Python Doc/ directory. Fabian> Do you have any pointers? How do you manage to generate the Fabian> nicely formatted HTML using what's in the Albatross tarball? Fabian> :) I suppose it is mostly dumb luck and persistence that has ended up with a combination of tools that seem to produce the right result. This is what dpkg tells me I am using: ii dia 0.88.1-3 Diagram editor ii dia-common 0.88.1-3 Diagram editor (common files) ii latex2html 2000-beta1-6 LaTeX to HTML translator. Later versions of dia have changed the font handling in a way that causes all of the diagrams to break. Hopefully this will be addressed in subsequent releases so we can stop using back releases. If not we may have to change our diagram tool. The Python 2.2 source includes a collection of files that provide many useful latex macros and a useful program to drive the formatting process. To my knowledge these are not included in any Debian package. Look in the Doc/tools and Doc/texinputs directories. - Dave -- http://www.object-craft.com.au From gnb at itga.com.au Mon Jun 2 10:35:09 2003 From: gnb at itga.com.au (Gregory Bond) Date: Mon, 02 Jun 2003 10:35:09 +1000 Subject: [albatross-users] Re: Debian package of Albatross In-Reply-To: Your message of 02 Jun 2003 10:30:28 +1000. Message-ID: <200306020035.KAA17809@lightning.itga.com.au> Or just fetch / package the pre-formatted doc files that Dave puts on the web. (This is what I do with the FreeBSD port.) Even easier after he starts freezing the doc tarball with each release. [hint hint!] From djc at object-craft.com.au Mon Jun 2 10:58:35 2003 From: djc at object-craft.com.au (Dave Cole) Date: 02 Jun 2003 10:58:35 +1000 Subject: [albatross-users] Simple random mode demo app In-Reply-To: <1054456495.5387.26.camel@localhost> References: <1054427612.22691.22.camel@localhost> <1054456495.5387.26.camel@localhost> Message-ID: > Sorry, the 1st URL should be > http://mattgoodall.dyndns.org/~matt/albatross/test/test.py. Had a bit of a play and looked at some of the code. I very much like the code that transparently handles cgi and mod_python deployment. One change though: if __name__ == '__main__': # CGI entry point from albatross.cgiapp import Request app = App() app.run(Request()) else: # mod_python entry point from albatross.apacheapp import Request def handler(req): app = App() return app.run(Request(req)) The mod_python code should be changed to this: # mod_python entry point from albatross.apacheapp import Request app = App() def handler(req): return app.run(Request(req)) If you instantiate the application once then you get the benefit of caching of both templates and page modules. > > * Using the tree tag to display a categorised view of what's in > > the test app. Nice use of style sheets to indent. > > * Custom tags: one that inserts the current time, one that > > displays its content in a nicely coloured box and one that > > caches the content to disk for a period of time. The content caching tag is a work of genius. Maybe you could expand on the idea and implement a content cache mixin that could be inherited by the application class. This would then ensure that the cached content was loaded only once (for mod_python) applications. I would love to add a cache like that to Albatross. - Dave -- http://www.object-craft.com.au From fabbe at paniq.net Mon Jun 2 16:16:06 2003 From: fabbe at paniq.net (Fabian Fagerholm) Date: 02 Jun 2003 09:16:06 +0300 Subject: [albatross-users] Re: Debian package of Albatross In-Reply-To: <200306020035.KAA17809@lightning.itga.com.au> References: <200306020035.KAA17809@lightning.itga.com.au> Message-ID: <1054534566.926.3.camel@kernel> On Mon, 2003-06-02 at 03:35, Gregory Bond wrote: > Or just fetch / package the pre-formatted doc files that Dave puts on the web. > (This is what I do with the FreeBSD port.) Even easier after he starts freezing > the doc tarball with each release. That's one approach, but in order to keep the source .deb small, I'd rather generate the documentation from the LaTeX source. This has the added benefit of only one upstream tarball with everything in the same place. Had I not solved the HTML generation problem, I would probably have gone for this solution instead. Thanks for the suggestion! -- Fabian Fagerholm paniq.net From fabbe at paniq.net Mon Jun 2 16:51:27 2003 From: fabbe at paniq.net (Fabian Fagerholm) Date: 02 Jun 2003 09:51:27 +0300 Subject: [albatross-users] Re: Debian package of Albatross In-Reply-To: References: <1053106526.25320.4.camel@kernel> <1053719977.5167.21.camel@kernel> Message-ID: <1054536687.928.40.camel@kernel> On Mon, 2003-06-02 at 03:30, Dave Cole wrote: > When I first used the Python documentation tools I tried to extract > the files that we needed from the distribution. After days of > frustration I decided to just use them from the unpacked distribution > directory. After days of frustration, I managed to figure out exactly which files were needed from the Python Doc/ directory. No, really, I just went through each and every file one by one, renamed it to .REMOVE and ran the build. If it failed, I would know that that file was needed. Afterwards, I just removed *.REMOVE and voila... > It would be a big help if there was a Debian package for > the cools tools and files in the Python Doc/ directory. I will take a look at this, time permitting. > I suppose it is mostly dumb luck and persistence that has ended up > with a combination of tools that seem to produce the right result. > This is what dpkg tells me I am using: > > ii dia 0.88.1-3 Diagram editor > ii dia-common 0.88.1-3 Diagram editor (common files) > ii latex2html 2000-beta1-6 LaTeX to HTML translator. I just noticed my pdf and ps versions of the docs are using different fonts than the ones you are generating. I'm almost certain that this is due to some font not being installed on my system. It has to be LaTeX -related, but I really don't know where to look. Perhaps you could mail me (privately, to reduce list clutter) the output of apt-cache search font | awk '{print $1}' | xargs dpkg --list or better, the name of the missing package, should you happen to have a vivid mental picture of it ;) > Later versions of dia have changed the font handling in a way that > causes all of the diagrams to break. Hopefully this will be addressed > in subsequent releases so we can stop using back releases. If not we > may have to change our diagram tool. My packages build-depend on dia (>= 0.88.1). The font issue is related to the use of GTK2, and is documented (/usr/share/doc/dia-common/NEWS.gz on Debian systems): ... dia-0.91-pre1: 31-Jan-2003 * Dia now uses Gtk2 which makes it look much prettier (menu icons, scrolling menus, less flicker, better international text support, ...) * Dia tries to follow the Gnome User Interface Guidelines which should make it more consistent with the Gnome2 desktop * Requires libgtk2.x instead of libgtk1.2. FIXME: document exactly what we need (do it in INSTALL too) * Relies on FreeType (pangoft2) for all Unix-side text handling. * Since text handling is totally changed, old diagrams will have different text sizes. ... The diagrams are a little bit different with 0.91 and later versions, mainly the fonts are smaller and hence there's a lot less white space. Are you seeing the same phenomenon or do you see other breakage? Since there's a difference in output between 0.88 and >=0.91, and since I don't think the dia authors are going to bend over backwards to fix this, I'm going to build-depend on >=0.91 and adjust the diagrams. Would it be fine with you if I contributed the adjusted diagrams? -- Fabian Fagerholm paniq.net From fabbe at paniq.net Mon Jun 2 16:53:18 2003 From: fabbe at paniq.net (Fabian Fagerholm) Date: 02 Jun 2003 09:53:18 +0300 Subject: [albatross-users] Update: Albatross Debian packages In-Reply-To: <1054377937.1093.35.camel@kernel> References: <1054377937.1093.35.camel@kernel> Message-ID: <1054536798.926.43.camel@kernel> On Sat, 2003-05-31 at 13:45, Fabian Fagerholm wrote: > The packages are available at > http://people.paniq.net/~fabbe/debian/albatross/ > > Some outstanding issues remain; I'm still having trouble generating the > HTML documentation. However, I think I may have found the cause for > this. The next update of the packages will probably fix this issue. The updated packages are now available. Some font issues remain in the PDF and PostScript versions. -- Fabian Fagerholm paniq.net From matt at pollenation.net Tue Jun 3 09:00:11 2003 From: matt at pollenation.net (Matt Goodall) Date: 03 Jun 2003 00:00:11 +0100 Subject: [albatross-users] Simple random mode demo app In-Reply-To: References: <1054427612.22691.22.camel@localhost> <1054456495.5387.26.camel@localhost> Message-ID: <1054594811.4720.43.camel@localhost> On Mon, 2003-06-02 at 01:58, Dave Cole wrote: > > Sorry, the 1st URL should be > > http://mattgoodall.dyndns.org/~matt/albatross/test/test.py. > > Had a bit of a play and looked at some of the code. > > I very much like the code that transparently handles cgi and > mod_python deployment. One change though: > > if __name__ == '__main__': > # CGI entry point > from albatross.cgiapp import Request > app = App() > app.run(Request()) > else: > # mod_python entry point > from albatross.apacheapp import Request > def handler(req): > app = App() > return app.run(Request(req)) > > The mod_python code should be changed to this: > > # mod_python entry point > from albatross.apacheapp import Request > app = App() > def handler(req): > return app.run(Request(req)) > > If you instantiate the application once then you get the benefit of > caching of both templates and page modules. Oh yeah, thanks for spotting that. Incidentally, I've started a FastCGI Request class based on the fcgi module. The basics are working (i.e. it serves a page) but I have not tried much more with it yet. fcgi seems quite nice, especially since it works for both standard CGI and FastCGI. Anyway, once I know it's working I'll post it to the list. > > > > * Using the tree tag to display a categorised view of what's in > > > the test app. > > Nice use of style sheets to indent. > > > > * Custom tags: one that inserts the current time, one that > > > displays its content in a nicely coloured box and one that > > > caches the content to disk for a period of time. > > The content caching tag is a work of genius. Thanks :) although I admit to seeing the idea in some JSP taglib. Albatross custom tags are **so** simple compared to JSP taglibs although they are also a bit simpler. > > Maybe you could expand on the idea and implement a content cache mixin > that could be inherited by the application class. This would then > ensure that the cached content was loaded only once (for mod_python) > applications. Sounds sensible although doesn't that only make sense if the content is cached in memory? I suppose the implementation could persist the cache to the file system and keep a copy in memory. I would need to think about concurrency issues but so does the FSCache class (no file locking!). So yeah ... I'm convinced. I was also planning on extending the cache tag to allow the "scope" of cached content to be set i.e. per-application, per-user, etc. > > I would love to add a cache like that to Albatross. I'll see what I can do to supply one then. > > - Dave From matt at pollenation.net Tue Jun 3 11:22:16 2003 From: matt at pollenation.net (Matt Goodall) Date: 03 Jun 2003 02:22:16 +0100 Subject: [albatross-users] FastCGI and SCGI Message-ID: <1054603336.4720.234.camel@localhost> Hi, I have started to implement a FastCGI (http://www.fastcgi.com/) Request class, mostly to see how it works. The basics are implemented but I need to complete it and check it works correctly. The other possibility is a SCGI (http://www.mems-exchange.org/software/scgi/) Request but I know nothing about that so far. Both seem to be in (reasonably) active development but I have no idea how many people actually use these CGI-like interfaces. Anyone got any facts and figures? I'll probably finish the FastCGI Request anyway but is this something people are actually interested in? Would it be a useful contribution to the Albatross code? Cheers, Matt From bgg at object-craft.com.au Tue Jun 3 11:34:08 2003 From: bgg at object-craft.com.au (Ben Golding) Date: Tue, 3 Jun 2003 11:34:08 +1000 Subject: [albatross-users] Mac OS X al-session-daemon start-up item Message-ID: <78AE3F5E-9563-11D7-AC51-003065907038@object-craft.com.au> I created a start-up item that launches the Albatross session server on Mac OS X when the machine boots up. To install it, you just need to drag the folder into /Library/StartupItems and it will be started automatically on reboot. Ben. -------------- next part -------------- A non-text attachment was scrubbed... Name: Al-session Type: application/octet-stream Size: 131 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: StartupParameters.plist Type: application/octet-stream Size: 609 bytes Desc: not available URL: From tchur at optushome.com.au Tue Jun 3 12:46:33 2003 From: tchur at optushome.com.au (Tim Churches) Date: Tue, 03 Jun 2003 12:46:33 +1000 Subject: [albatross-users] Simple random mode demo app Message-ID: <200306030246.h532kXt18726@mail024.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From tchur at optushome.com.au Tue Jun 3 12:47:59 2003 From: tchur at optushome.com.au (Tim Churches) Date: Tue, 03 Jun 2003 12:47:59 +1000 Subject: [albatross-users] FastCGI and SCGI Message-ID: <200306030247.h532lxF01301@mail019.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From sheila at thinkspot.net Tue Jun 3 16:37:22 2003 From: sheila at thinkspot.net (Sheila King) Date: Mon, 02 Jun 2003 23:37:22 -0700 Subject: [albatross-users] cookie error in sessionfile.py Message-ID: <48307101.1054597042@SHEILA-LAPTOP> Today I asked some of the members on my team to test the application I've been building. It doesn't do a whole lot yet. Mostly authentication stuff. Create new account. Log in. Log out. Request lost password. Expires after x minutes of inactivity. Anyhow, I had tested it on Mozilla 1.3 and 1.0 and IE 5.0 and 6.0 on two different computers. Never a problem with loading templates and simply displaying pages. So I show it to my boss today and first thing, as soon as she goes to the URL, she gets a traceback. And I look and tell her it is a cookie thing, and she has them enabled and she fiddled around with her browser, and no matter what, she couldn't view the app. Just errors and tracebacks. Here is a sample traceback: ---------------------------------------- Template traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python2.2/site-packages/albatross/app.py", line 142, in run self.load_session(ctx) File "/usr/lib/python2.2/site-packages/albatross/app.py", line 204, in load_session ctx.load_session() File "/usr/lib/python2.2/site-packages/albatross/sessionfile.py", line 46, in load_session sesid = self._get_sesid_from_cookie() File "/usr/lib/python2.2/site-packages/albatross/sessionfile.py", line 37, in _get_sesid_from_cookie return os.path.basename(c[self.app.ses_appid()].value) File "/usr/lib/python2.2/UserDict.py", line 14, in __getitem__ def __getitem__(self, key): return self.data[key] KeyError: appid ------------------------------------------ In an attempt at resolving this situation, I made the following change in the sessionfile.py file: To this function: (starting at line 32) ------------------------------------------ def _get_sesid_from_cookie(self): hdr = self.request.get_header('Cookie') if hdr: c = Cookie.SimpleCookie(hdr) try: return os.path.basename(c[self.app.ses_appid()].value) except OSError: pass return None ------------------------------------------ I simply added one more exception check: ------------------------------------------ def _get_sesid_from_cookie(self): hdr = self.request.get_header('Cookie') if hdr: c = Cookie.SimpleCookie(hdr) try: return os.path.basename(c[self.app.ses_appid()].value) except OSError: pass ### KeyError fix except KeyError: pass return None ------------------------------------------ and that seems to have solved the problem. By the way, I had two other people test the app before I made the fix, and they had no problems either. The person with the issue was using IE 5.5, but two of the other testers also used that browser, and had no issues. FWIW, it seems that her browser was sending a cookie. How, I have no idea? To my knowledge, this person has never before visited the site/directory where my app was stored. Anyhow, her browser was sending a cookie, but not one my app had set, and then my app was trying to lookup the cookie by the appid name, and failing. So, I just old the app to ignore a KeyError, and it all seems fixed? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From neel at mediapulse.com Wed Jun 4 02:18:29 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 3 Jun 2003 12:18:29 -0400 Subject: [albatross-users] A better page system Message-ID: All, The current Albatross system gives us "prev" and "next" links/buttons; but I was wondering if anyone had expanded upon this yet. I'd like to add to the system "first", "last" as well as "now showing 20-29 of 354". Extra credit will be page numbers, so you can jump right to page 8 in the result set and maybe some logic to group up the pages, like "1 2 3 4 5 10 20 30 40" and then when on page 25 "10 20 23 24 25 26 27 30 40". I can start on this myself, but if there is something out there to use, leverage from I don't want to re-invent it. At point I'd like to add an alx-sqlfor to my axe tags (shame less plug: http://axe.sourceforge.net) that has this type of paging system, but also is "database aware" so that it is not quering the entire result set at once, just those records that are to be dispayed; but still knows where in the set you are and how larg the set is. Simply put, and advanced database cursor that can cope with the stateless medium of the web. Thanks, Mike Ps. How close is that fabled new version of albatross? =) From matt at pollenation.net Wed Jun 4 08:51:08 2003 From: matt at pollenation.net (Matt Goodall) Date: 03 Jun 2003 23:51:08 +0100 Subject: [albatross-users] New tag reference Message-ID: <1054680665.25975.33.camel@localhost> This is mostly for Dave (Cole) ... Way back in the mists of time (22 May) you posted a message with a link, http://www.object-craft.com.au/~djc/albatross/tag-ref.html, to the tag reference of the documentation you've been working on. I had a quick look through then but never got around to providing any feedback so I'm doing it now. I like the new tag reference very much. The table of contents itself now summarises the attributes supported by the tags really nicely. That makes it much easier to a) guess what's possible with the tags in the first place and b) find the relevant information much more quickly. The content of the documentation is also much clearer as each section of the tag reference now covers less and in more detail. The links to other sections of the reference is also great. Basically, it looks really good. I'm looking forward to the end result ... hint, hint ;-). Cheers, Matt From andrewm at object-craft.com.au Wed Jun 4 10:51:21 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 04 Jun 2003 10:51:21 +1000 Subject: [albatross-users] cookie error in sessionfile.py In-Reply-To: Message from Sheila King of "Mon, 02 Jun 2003 23:37:22 MST." <48307101.1054597042@SHEILA-LAPTOP> References: <48307101.1054597042@SHEILA-LAPTOP> Message-ID: <20030604005121.B12933C420@coffee.object-craft.com.au> > def _get_sesid_from_cookie(self): > hdr = self.request.get_header('Cookie') > if hdr: > c = Cookie.SimpleCookie(hdr) > try: > return os.path.basename(c[self.app.ses_appid()].value) > except OSError: > pass > ### KeyError fix > except KeyError: > pass > return None >------------------------------------------ > >and that seems to have solved the problem. By the way, I had two other >people test the app before I made the fix, and they had no problems either. That's the right fix. Looking at the CVS history, I made this change in session.py in March 2002, but missed the instance in sessionfile.py until November 2002 (after the 1.01 release). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Thu Jun 5 03:33:04 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 4 Jun 2003 13:33:04 -0400 Subject: [albatross-users] New tag reference Message-ID: Looks like I missed this post too, but this looks really great. The one part I would add is an example of each tag on the form side being parsed on submission, i.e. showing how to get at the data from a etc. It is nice there is some explaintion of how albatross internally handles the request, but in a perfect world I don't need to know the details of why it works =) Mike > -----Original Message----- > From: Matt Goodall [mailto:matt at pollenation.net] > Sent: Tuesday, June 03, 2003 6:51 PM > To: albatross-users at object-craft.com.au > Subject: [albatross-users] New tag reference > > > This is mostly for Dave (Cole) ... > > Way back in the mists of time (22 May) you posted a > message with a link, > http://www.object-craft.com.au/~djc/albatross/tag-ref.htm l, to the tag reference of the documentation you've been working on. I had a quick look through then but never got around to providing any feedback so I'm doing it now. I like the new tag reference very much. The table of contents itself now summarises the attributes supported by the tags really nicely. That makes it much easier to a) guess what's possible with the tags in the first place and b) find the relevant information much more quickly. The content of the documentation is also much clearer as each section of the tag reference now covers less and in more detail. The links to other sections of the reference is also great. Basically, it looks really good. I'm looking forward to the end result ... hint, hint ;-). Cheers, Matt _______________________________________________ Albatross-users mailing list Albatross-users at object-craft.com.au https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users From djc at object-craft.com.au Thu Jun 5 10:08:35 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 10:08:35 +1000 Subject: [albatross-users] New tag reference In-Reply-To: <1054680665.25975.33.camel@localhost> References: <1054680665.25975.33.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> The content of the documentation is also much clearer as each Matt> section of the tag reference now covers less and in more Matt> detail. The links to other sections of the reference is also Matt> great. Matt> Basically, it looks really good. I'm looking forward to the end Matt> result ... hint, hint ;-). Thanks. I am continuing my work on the tag reference. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jun 5 10:12:01 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 10:12:01 +1000 Subject: [albatross-users] New tag reference In-Reply-To: References: Message-ID: >>>>> "Michael" == Michael C Neel writes: Michael> Looks like I missed this post too, but this looks really Michael> great. The one part I would add is an example of each tag on Michael> the form side being parsed on submission, i.e. showing how to Michael> get at the data from a etc. I am not sure that I understand what you are asking here. Michael> It is nice there is some explaintion of how albatross Michael> internally handles the request, but in a perfect world I Michael> don't need to know the details of why it works =) On reflection I have decided to not to bother with the documentation of mixin function usage. That means that the following will be removed: http://www.object-craft.com.au/~djc/albatross/tag-form-mixin.html - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jun 5 10:18:23 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 10:18:23 +1000 Subject: [albatross-users] A better page system In-Reply-To: References: Message-ID: >>>>> "Michael" == Michael C Neel writes: Michael> All, The current Albatross system gives us "prev" and "next" Michael> links/buttons; but I was wondering if anyone had expanded Michael> upon this yet. I'd like to add to the system "first", "last" Michael> as well as "now showing 20-29 of 354". Extra credit will be Michael> page numbers, so you can jump right to page 8 in the result Michael> set and maybe some logic to group up the pages, like "1 2 3 4 Michael> 5 10 20 30 40" and then when on page 25 "10 20 23 24 25 26 27 Michael> 30 40". I can start on this myself, but if there is Michael> something out there to use, leverage from I don't want to Michael> re-invent it. That would be a nice addition to the pagination. The current scheme allows you to paginate sequences without needing to know their length. By adding the "now showing 20-29 of 354" you would need to determine the length of the sequence. Is that a problem? I am not sure. Michael> Ps. How close is that fabled new version of albatross? =) The code has been ready for some time. I need to keep plugging away at the documentation. I don't really have much against an interim/pre release that is followed up with a real release once I finish updating the documentation. What are your thoughts Andrew? - Dave -- http://www.object-craft.com.au From matt at pollenation.net Thu Jun 5 10:46:37 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jun 2003 01:46:37 +0100 Subject: [albatross-users] FastCGI Implementation Message-ID: <1054773997.1073.105.camel@localhost> Hi all, I've finished the FastCGI support module, it's attached. It was very easy and seems to work ok :). I've run both stateful and random apps here although they're not very complicated. The fcgiapp module contains the usual class, Request, and a method, running(). I chose to extend cgiapp.Request since the implementation is mostly identical. The fcgiapp module uses Robin Dunn's fcgi.py, available via the FastCGI site, http://www.fastcgi.com. Here's the direct link - http://alldunn.com/python/fcgi.py. To use fcgiapp, change your application startup code to: import fcgiapp app = App() while fcgiapp.running(): app.run(fcgiapp.Request()) The while loop runs until running() returns 0, i.e. until the web server's FastCGI module decides to shut you down. fcgi also supports straight CGI so you can use the same code when running as a CGI. All that happens for CGI is that the loop only runs once. Tim - since you expressed an interest in this, could you try some more realistic tests? Dave, Andrew - If you want this, it's yours. Feel free to repackage it, rewrite it, refactor it with cgiapp etc. Heck, you can even add some comments if you want ;-). Hope this is useful. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net -------------- next part -------------- A non-text attachment was scrubbed... Name: fcgiapp.py Type: text/x-python Size: 572 bytes Desc: not available URL: From matt at pollenation.net Thu Jun 5 10:52:21 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jun 2003 01:52:21 +0100 Subject: [albatross-users] A better page system In-Reply-To: References: Message-ID: <1054774341.5559.117.camel@localhost> On Thu, 2003-06-05 at 01:18, Dave Cole wrote: > Michael> Ps. How close is that fabled new version of albatross? =) > > The code has been ready for some time. I need to keep plugging away > at the documentation. I don't really have much against an interim/pre > release that is followed up with a real release once I finish updating > the documentation. > > What are your thoughts Andrew? > > - Dave I'm not Andrew ;-) but this would be great. I would like to experiment with the new file upload support for a project that might be starting in a few weeks. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From tchur at optushome.com.au Thu Jun 5 10:56:24 2003 From: tchur at optushome.com.au (Tim Churches) Date: Thu, 05 Jun 2003 10:56:24 +1000 Subject: [albatross-users] A better page system Message-ID: <200306050056.h550uOI17109@mail018.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From matt at pollenation.net Thu Jun 5 11:00:40 2003 From: matt at pollenation.net (Matt Goodall) Date: 05 Jun 2003 02:00:40 +0100 Subject: [albatross-users] Documentation suggestion Message-ID: <1054774839.8726.127.camel@localhost> I think it would be very useful to mention the ExecuteMixin in the custom tag section of the documentation. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From tchur at optushome.com.au Thu Jun 5 11:02:17 2003 From: tchur at optushome.com.au (Tim Churches) Date: Thu, 05 Jun 2003 11:02:17 +1000 Subject: [albatross-users] Re: FastCGI Implementation Message-ID: <200306050102.h5512HG06090@mail020.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From djc at object-craft.com.au Thu Jun 5 11:38:24 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 11:38:24 +1000 Subject: [albatross-users] Documentation suggestion In-Reply-To: <1054774839.8726.127.camel@localhost> References: <1054774839.8726.127.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> I think it would be very useful to mention the ExecuteMixin in Matt> the custom tag section of the documentation. Good point. That is the best place for it. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jun 5 11:42:33 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 11:42:33 +1000 Subject: [albatross-users] Re: FastCGI Implementation In-Reply-To: <200306050102.h5512HG06090@mail020.syd.optusnet.com.au> References: <200306050102.h5512HG06090@mail020.syd.optusnet.com.au> Message-ID: >>>>> "Tim" == Tim Churches writes: Tim> Matt Goodall wrote: >> Hi all, >> >> I've finished the FastCGI support module, it's attached. It was >> very easy and seems to work ok :). I've run both stateful and >> random apps here although they're not very complicated. >> >> The fcgiapp module contains the usual class, Request, and a method, >> running(). I chose to extend cgiapp.Request since the >> implementation is mostly identical. >> >> The fcgiapp module uses Robin Dunn's fcgi.py, available via the >> FastCGI site, http://www.fastcgi.com. Here's the direct link - >> http://alldunn.com/python/fcgi.py. >> >> To use fcgiapp, change your application startup code to: >> >> import fcgiapp app = App() while fcgiapp.running(): >> app.run(fcgiapp.Request()) >> >> The while loop runs until running() returns 0, i.e. until the web >> server's FastCGI module decides to shut you down. fcgi also >> supports straight CGI so you can use the same code when running as >> a CGI. All that happens for CGI is that the loop only runs once. >> >> Tim - since you expressed an interest in this, could you try some >> more realistic tests? Tim> Fabulous! Yes, when Andrew comes in next week (he is doing Tim> Albatross contract work with us, the results of which we hope to Tim> be able to open source and which are very, very cool - at least I Tim> think so) we might take an hour out to try to quickly Tim> FastCGI-enable an existing Albatross-based statistical analysis Tim> application we have. We'll let you know how it goes. I am very interested in seeing the results of this investigation. Having a FastCGI capability in Albatross would open up all sort of possibilities. >> Dave, Andrew - If you want this, it's yours. Feel free to >> repackage it, rewrite it, refactor it with cgiapp etc. Heck, you >> can even add some comments if you want ;-). Tim> I think this would be a fabulous addition to the core Albatross Tim> library (assuming it works OK - we'll see next week - but it is Tim> beautifully simple, so I suspect it will). I could not agree more. - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Thu Jun 5 11:44:30 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 05 Jun 2003 11:44:30 +1000 Subject: [albatross-users] A better page system In-Reply-To: Message from Dave Cole of "05 Jun 2003 10:18:23 +1000." References: Message-ID: <20030605014431.052903C420@coffee.object-craft.com.au> >Michael> Ps. How close is that fabled new version of albatross? =) > >The code has been ready for some time. I need to keep plugging away >at the documentation. I don't really have much against an interim/pre >release that is followed up with a real release once I finish updating >the documentation. > >What are your thoughts Andrew? Yes, I think a pre-release would be a good thing. It probably shouldn't be announced on the python-* list. Do we want to roll the unicode support into the next release? When you need unicode support, you really need unicode support. The biggest gotchya is the template output is cast to unicode strings, which means that the 'ascii' decoder is applied to all your traditional string output - the 'ascii' decoder will throw an exception if it's input is not 7-bit clean. Put another way, if your application only uses characters in the range 0-127, the unicode version of albatross works identically to the old version. However, if you are using foreign character sets (accented characters, etc) with characters in the range 128-255, your application will need to be changed (but the results are much cleaner). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Thu Jun 5 11:50:47 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 11:50:47 +1000 Subject: [albatross-users] FastCGI Implementation In-Reply-To: <1054773997.1073.105.camel@localhost> References: <1054773997.1073.105.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Hi all, I've finished the FastCGI support module, it's Matt> attached. It was very easy and seems to work ok :). I've run Matt> both stateful and random apps here although they're not very Matt> complicated. Looking at the code I am amazed at how little code was required to get this going. Matt> Tim - since you expressed an interest in this, could you try Matt> some more realistic tests? I am very excited about this. Matt> Dave, Andrew - If you want this, it's yours. Feel free to Matt> repackage it, rewrite it, refactor it with cgiapp etc. Heck, you Matt> can even add some comments if you want ;-). Excellent! Thank you very much for doing this. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Thu Jun 5 12:00:58 2003 From: djc at object-craft.com.au (Dave Cole) Date: 05 Jun 2003 12:00:58 +1000 Subject: [albatross-users] A better page system In-Reply-To: <20030605014431.052903C420@coffee.object-craft.com.au> References: <20030605014431.052903C420@coffee.object-craft.com.au> Message-ID: >>>>> "Andrew" == Andrew McNamara writes: Michael> Ps. How close is that fabled new version of albatross? =) >> The code has been ready for some time. I need to keep plugging >> away at the documentation. I don't really have much against an >> interim/pre release that is followed up with a real release once I >> finish updating the documentation. >> >> What are your thoughts Andrew? Andrew> Yes, I think a pre-release would be a good thing. It probably Andrew> shouldn't be announced on the python-* list. Yes. Andrew> Do we want to roll the unicode support into the next release? That might be a good idea. I am in two minds though. On one hand we want to get the new code out there, while on the other, the Unicode support has received limited testing. How many people are interested in trying and using the Unicode support? Should we merge it in now or later? Andrew> When you need unicode support, you really need unicode Andrew> support. The biggest gotchya is the template output is cast to Andrew> unicode strings, which means that the 'ascii' decoder is Andrew> applied to all your traditional string output - the 'ascii' Andrew> decoder will throw an exception if it's input is not 7-bit Andrew> clean. Andrew> Put another way, if your application only uses characters in Andrew> the range 0-127, the unicode version of albatross works Andrew> identically to the old version. However, if you are using Andrew> foreign character sets (accented characters, etc) with Andrew> characters in the range 128-255, your application will need to Andrew> be changed (but the results are much cleaner). You probably need to provide an example here. - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Thu Jun 5 13:00:38 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 05 Jun 2003 13:00:38 +1000 Subject: [albatross-users] A better page system In-Reply-To: Message from Dave Cole of "05 Jun 2003 12:00:58 +1000." References: <20030605014431.052903C420@coffee.object-craft.com.au> Message-ID: <20030605030038.AF0493C420@coffee.object-craft.com.au> >Andrew> Put another way, if your application only uses characters in >Andrew> the range 0-127, the unicode version of albatross works >Andrew> identically to the old version. However, if you are using >Andrew> foreign character sets (accented characters, etc) with >Andrew> characters in the range 128-255, your application will need to >Andrew> be changed (but the results are much cleaner). > >You probably need to provide an example here. Difficult to do without scaring people off... 8-) My first response when I encountered all the grief that unicode appears to create was "bugger this for a joke". But the reality is that unicode isn't the problem - the problem is the mess that existed before. Whereas you might previously have got away with outputing a variable containing an accented character (that's an umlat-a if this doesn't make it though e-mail): >>> import albatross >>> ctx = albatross.SimpleContext('.') >>> ctx.locals.name = 'H?ring' >>> albatross.Template(ctx, '', '''''').to_html(ctx) >>> ctx.flush_content() H?ring Now you will get a traceback: >>> import albatross >>> ctx = albatross.SimpleContext('.') >>> ctx.locals.name = 'H?ring' >>> albatross.Template(ctx, '', '''''').to_html(ctx) Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.3/site-packages/albatross/template.py", line 358, in to_html self.content.to_html(ctx) File "/usr/local/lib/python2.3/site-packages/albatross/template.py", line 152, in to_html item.to_html(ctx) File "/usr/local/lib/python2.3/site-packages/albatross/tags.py", line 1038, in to_html ctx.write_content(escape(value)) File "/usr/local/lib/python2.3/site-packages/albatross/tags.py", line 20, in escape text = unicode(text) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) This is because all standard strings are assumed to use the 'ascii' character set by python, rather than the browser-default iso-8859-1 character set. So when it converts a standard string to a unicode string, it uses the 'ascii' codec, rather than the 'iso-8859-1' codec. The "right" answer, if you are dealing with international character sets is probably to work with unicode throughout: >>> ctx.locals.name = u'H?ring' >>> albatross.Template(ctx, '', '''''').to_html(ctx) >>> ctx.flush_content() H?ring When you accept strings from other systems, you probably need to decode them explicitly: >>> ctx.locals.name = sys.stdin.readline().decode('iso-8859-1') -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Fri Jun 6 08:34:39 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 5 Jun 2003 18:34:39 -0400 Subject: [albatross-users] A better page system Message-ID: What is the case when the high ascii character appears in the template file? Is it okay there, or does it still cause the execption? If it's okay there, then I'm all for it being in this pre-release; if not a switch to disable unicode would be nice (it should be on by default IMHO than off, since we are supposed to all be using it now =p). Reason is I'm pretty sure my code is safe here, but templates come in from designers and who knows what Dreamweaver is doing. But I have albatross running quite a few sites here and I'd like to begin moving them back to a standard albatross and not my hacked version to do things like custom headers and multiple cookies - both of which I know are in the next release. Thanks, Mike From neel at mediapulse.com Fri Jun 6 08:44:13 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 5 Jun 2003 18:44:13 -0400 Subject: [albatross-users] New tag reference Message-ID: > Michael> Looks like I missed this post too, but this looks really > Michael> great. The one part I would add is an example > of each tag on > Michael> the form side being parsed on submission, i.e. > showing how to > Michael> get at the data from a etc. > > I am not sure that I understand what you are asking here. > What you have is: >>> import albatross >>> class Ctx(albatross.SimpleContext): ... def input_add(self, *args): ... print args ... >>> ctx = Ctx('.') >>> albatross.Template(ctx, '', ''' ... ... ''').to_html(ctx) ('file', 'resume', None, 0) >>> ctx.flush_content() What I'd like to see added after that is: # page module code, inside page_process(), saves the uploaded file if ctx.req_equals("resume") and len(ctx.locals.resume.value): filename = "/home/uploads/resumes/new_file.txt" file = open(filename, 'wb') file.writelines(ctx.locals.image.value) file.close() Actually, it should be alittle more than that, showing getting the filename as it was on the client's system - but this is off the top of my head and I don't remember where that's stored atm (hence the need for the reference =) Thanks, Mike From andrewm at object-craft.com.au Fri Jun 6 11:10:54 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Fri, 06 Jun 2003 11:10:54 +1000 Subject: [albatross-users] A better page system In-Reply-To: Message from "Michael C. Neel" of "Thu, 05 Jun 2003 18:34:39 -0400." References: Message-ID: <20030606011054.17AD43C419@coffee.object-craft.com.au> >What is the case when the high ascii character appears in the template >file? Is it okay there, or does it still cause the execption? If it's >okay there, then I'm all for it being in this pre-release; if not a >switch to disable unicode would be nice (it should be on by default IMHO >than off, since we are supposed to all be using it now =3Dp). > >Reason is I'm pretty sure my code is safe here, but templates come in >from designers and who knows what Dreamweaver is doing. But I have >albatross running quite a few sites here and I'd like to begin moving >them back to a standard albatross and not my hacked version to do things >like custom headers and multiple cookies - both of which I know are in >the next release. I suspect this will be a problem. There is no sensible answer without knowing what character set the input file uses. Python 2.3 added a magic string that can be added to .py files to flag their character set - we'll probably need to do the same. I think we'll skip the unicode support for the next release (due to these issues and a lack of time), but immediately after the release, we should put out a pre with unicode support so those who need and understand unicode can give feedback. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Sun Jun 8 01:06:16 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jun 2003 01:06:16 +1000 Subject: [albatross-users] Albatross 1.10 pre1 release Message-ID: I have just packaged up the 1.10pre1 release of Albatross. This announcement is only being sent to this list as the documentation updates are not yet complete. We are now including a summary of changes between releases in the back of the manual. http://www.object-craft.com.au/projects/albatross/albatross/changes.html I just realised that we have not mentioned the addition of the excellent FastCGI Request code sent by Matt Goodall. This will be fixed for the real release. We should be able to add a FastCGI sample to the documentation as well. Andrew and I have decided not to merge the Unicode changes in yet. The Unicode stuff really does require some documentation. Please have a look at the new release and do not hesitate to comment. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Sun Jun 8 08:23:11 2003 From: matt at pollenation.net (Matt Goodall) Date: 07 Jun 2003 23:23:11 +0100 Subject: [albatross-users] Updated FastCGI Request module Message-ID: <1055024591.153.378.camel@localhost> Hi, Attached is a new version of fcgiapp.py that works with 1.10pre1. I've changed a number of the sample apps in the 1.10pre1 distribution over to FastCGI and all seem to work fine. I've also tested it with the new file upload support (yippee!) and that seems to work too. If you want to try this out then replace albatross/fcpiapp.py in the 1.10pre1 distribution code and (re)install. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net -------------- next part -------------- A non-text attachment was scrubbed... Name: fcgiapp.py Type: text/x-python Size: 1108 bytes Desc: not available URL: From matt at pollenation.net Sun Jun 8 08:59:35 2003 From: matt at pollenation.net (Matt Goodall) Date: 07 Jun 2003 23:59:35 +0100 Subject: [albatross-users] Albatross 1.10 pre1 release In-Reply-To: References: Message-ID: <1055026774.18502.404.camel@localhost> Thanks guys! Everything I've tried so far is working fine but I have spotted a couple of things that need changing: * LICENCE still says (c) 2002. * The FAQ says that Python 1.5.2 or later is required but, in at least cgiapp and apacheapp, it looks like you've stopped using the string module in favour of the string object's methods. IIRC, string only became a first class object in 2.0. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From djc at object-craft.com.au Sun Jun 8 16:25:19 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jun 2003 16:25:19 +1000 Subject: [albatross-users] Updated FastCGI Request module In-Reply-To: <1055024591.153.378.camel@localhost> References: <1055024591.153.378.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> Hi, Attached is a new version of fcgiapp.py that works with Matt> 1.10pre1. Matt> I've changed a number of the sample apps in the 1.10pre1 Matt> distribution over to FastCGI and all seem to work fine. I've Matt> also tested it with the new file upload support (yippee!) and Matt> that seems to work too. Matt> If you want to try this out then replace albatross/fcpiapp.py in Matt> the 1.10pre1 distribution code and (re)install. I have committed the new version. Thanks. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 8 16:30:03 2003 From: djc at object-craft.com.au (Dave Cole) Date: 08 Jun 2003 16:30:03 +1000 Subject: [albatross-users] Albatross 1.10 pre1 release In-Reply-To: <1055026774.18502.404.camel@localhost> References: <1055026774.18502.404.camel@localhost> Message-ID: > Everything I've tried so far is working fine but I have spotted a couple > of things that need changing: > > * LICENCE still says (c) 2002. Updated > * The FAQ says that Python 1.5.2 or later is required but, in at > least cgiapp and apacheapp, it looks like you've stopped using > the string module in favour of the string object's methods. > IIRC, string only became a first class object in 2.0. Updated. Thanks again Matt. - Dave -- http://www.object-craft.com.au From andrewm at object-craft.com.au Mon Jun 9 17:46:39 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Mon, 09 Jun 2003 17:46:39 +1000 Subject: [albatross-users] Albatross 1.10 pre1 release In-Reply-To: Message from Matt Goodall of "07 Jun 2003 23:59:35 +0100." <1055026774.18502.404.camel@localhost> References: <1055026774.18502.404.camel@localhost> Message-ID: <20030609074639.DEA823C41B@coffee.object-craft.com.au> > * The FAQ says that Python 1.5.2 or later is required but, in at > least cgiapp and apacheapp, it looks like you've stopped using > the string module in favour of the string object's methods. > IIRC, string only became a first class object in 2.0. It should be mentioned that the intention for 1.10 is to drop support for 1.5.2. One particular reason to do this is that apply() is now deprecated, and while you don't normally see any difference, the warning machinery is invoked for every call, and it makes apply(fn, args) more than 300 times slower than the new-style fn(*args). See this thread: http://groups.google.com.au/groups?th=fbe9c932c8b5ad91 -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From matt at pollenation.net Tue Jun 10 07:35:40 2003 From: matt at pollenation.net (Matt Goodall) Date: 09 Jun 2003 22:35:40 +0100 Subject: [albatross-users] Albatross 1.10 pre1 release In-Reply-To: <20030609074639.DEA823C41B@coffee.object-craft.com.au> References: <1055026774.18502.404.camel@localhost> <20030609074639.DEA823C41B@coffee.object-craft.com.au> Message-ID: <1055194539.3960.20.camel@localhost> The apply() builtin is something I've been meaning to look at for ages. I keep seeing it in framework type code and understood what it must be doing but I have never actually had a need to use it. It turns out I've been doing it "right" by avoiding it all the time without realising :). IIRC, I just tried calling the function object in the way I expected it to work. It worked so I carried on using it ... isn't Python wonderful sometimes. Thanks for enlightening me Andrew. - Matt On Mon, 2003-06-09 at 08:46, Andrew McNamara wrote: > > * The FAQ says that Python 1.5.2 or later is required but, in at > > least cgiapp and apacheapp, it looks like you've stopped using > > the string module in favour of the string object's methods. > > IIRC, string only became a first class object in 2.0. > > It should be mentioned that the intention for 1.10 is to drop support for > 1.5.2. One particular reason to do this is that apply() is now deprecated, > and while you don't normally see any difference, the warning machinery is > invoked for every call, and it makes apply(fn, args) more than 300 times > slower than the new-style fn(*args). See this thread: > > http://groups.google.com.au/groups?th=fbe9c932c8b5ad91 From andrewm at object-craft.com.au Wed Jun 11 09:59:57 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 11 Jun 2003 09:59:57 +1000 Subject: [albatross-users] Albatross 1.10 pre1 release In-Reply-To: Message from Matt Goodall of "09 Jun 2003 22:35:40 +0100." <1055194539.3960.20.camel@localhost> References: <1055026774.18502.404.camel@localhost> <20030609074639.DEA823C41B@coffee.object-craft.com.au> <1055194539.3960.20.camel@localhost> Message-ID: <20030610235957.D960B3C41B@coffee.object-craft.com.au> >The apply() builtin is something I've been meaning to look at for ages. >I keep seeing it in framework type code and understood what it must be >doing but I have never actually had a need to use it. It turns out I've >been doing it "right" by avoiding it all the time without realising :). > >IIRC, I just tried calling the function object in the way I expected it >to work. It worked so I carried on using it ... isn't Python wonderful >sometimes. Apply() and the newer construct are used where the argument list to the function is determined at run time. For example, you might be implementing a file-like class, and want to pass your arguments through to open(): class FooFile: def __init__(self, filename, *args): self.filename = filename self.file = open(filename, *args) The last line, could, of course, be written: self.file = apply(open, (filename,) + args) -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From paulhart at redchocolate.ca Sun Jun 15 13:00:57 2003 From: paulhart at redchocolate.ca (Paul Hart) Date: Sat, 14 Jun 2003 23:00:57 -0400 Subject: [albatross-users] mod_python / RandomModularSessionApp bug Message-ID: <961DD7DA-9EDD-11D7-B6D0-000393CC268A@redchocolate.ca> Hi all, I've just started playing with Albatross; it's been a joy to work with so far, and it's allowed me to do some pretty crazy stuff in very few lines of code. I'm having problems with RandomModularSessionApp. My environment is: OpenBSD 3.3; Python 2.2.1; mod_python 3.0.3; apache 2.0.45. Unfortunately, when running the app inside mod_python, the following stack trace is always generated: --- START TRACE --- Template traceback (most recent call last): Traceback (most recent call last): File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line 143, in run self.load_page(ctx) File "/usr/local/lib/python2.2/site-packages/albatross/randompage.py", line 28, in load_page ctx.redirect(self.start_page()) File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line 121, in redirect new_loc = self.redirect_url(loc) File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line 113, in redirect_url return urlparse.urlunparse(('http', self.request.get_servername(), File "/usr/local/lib/python2.2/site-packages/albatross/apacheapp.py", line 34, in get_servername return self.__req.connection.server.server_hostname AttributeError: server --- END TRACE --- The problem is that, as of mod_python 3.0.3 (at least), there is no 'server' member inside the connection object. Instead, all that exists is the 'base_server' member. This is no good to me though; I'm running on a machine with several virtual hosts, and base_server returns what it considers to be the default virtual host, which isn't the one that I'm working with. I don't know if there is a fix; I'm very new with Python, and have no real understanding of the coding behind mod_python, apart from being able to hack at Albatross enough to prove that base_server wasn't what I was looking for (if it had been, I would have submitted some kind of patch), and finding out that the os.environ items in mod_python are completely useless to me ;) If anyone has a suggestion (that isn't "use CGI" ;), I'd appreciate it. Thanks, Paul Hart From paulhart at redchocolate.ca Sun Jun 15 13:32:34 2003 From: paulhart at redchocolate.ca (Paul Hart) Date: Sat, 14 Jun 2003 23:32:34 -0400 Subject: [albatross-users] mod_python / RandomModularSessionApp bug In-Reply-To: <961DD7DA-9EDD-11D7-B6D0-000393CC268A@redchocolate.ca> Message-ID: <00F7BEE2-9EE2-11D7-B6D0-000393CC268A@redchocolate.ca> Whoops, so I spoke too soon; I think I have a solution. in apacheapp.py line 33, change the following: def get_servername(self): return self.__req.connection.server.server_hostname into the following: def get_servername(self): try: return self.__req.connection.server.server_hostname except: return self.__req.hostname That appears to be working for me. Maybe that's been fixed in 1.10pre1; because I want to work with release software, I haven't checked. Hope that helps! Paul On Saturday, June 14, 2003, at 11:00 PM, Paul Hart wrote: > Hi all, > > I've just started playing with Albatross; it's been a joy to work with > so far, and it's allowed me to do some pretty crazy stuff in very few > lines of code. > > I'm having problems with RandomModularSessionApp. My environment is: > > OpenBSD 3.3; > Python 2.2.1; > mod_python 3.0.3; > apache 2.0.45. > > Unfortunately, when running the app inside mod_python, the following > stack trace is always generated: > > --- START TRACE --- > Template traceback (most recent call last): > > Traceback (most recent call last): > File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line > 143, in run > self.load_page(ctx) > File > "/usr/local/lib/python2.2/site-packages/albatross/randompage.py", line > 28, in load_page > ctx.redirect(self.start_page()) > File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line > 121, in redirect > new_loc = self.redirect_url(loc) > File "/usr/local/lib/python2.2/site-packages/albatross/app.py", line > 113, in redirect_url > return urlparse.urlunparse(('http', self.request.get_servername(), > File > "/usr/local/lib/python2.2/site-packages/albatross/apacheapp.py", line > 34, in get_servername > return self.__req.connection.server.server_hostname > AttributeError: server > --- END TRACE --- > > The problem is that, as of mod_python 3.0.3 (at least), there is no > 'server' member inside the connection object. Instead, all that exists > is the 'base_server' member. This is no good to me though; I'm running > on a machine with several virtual hosts, and base_server returns what > it considers to be the default virtual host, which isn't the one that > I'm working with. > > I don't know if there is a fix; I'm very new with Python, and have no > real understanding of the coding behind mod_python, apart from being > able to hack at Albatross enough to prove that base_server wasn't what > I was looking for (if it had been, I would have submitted some kind of > patch), and finding out that the os.environ items in mod_python are > completely useless to me ;) > > If anyone has a suggestion (that isn't "use CGI" ;), I'd appreciate it. > > Thanks, > > Paul Hart > > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross- > users From andrewm at object-craft.com.au Tue Jun 17 14:53:52 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 17 Jun 2003 14:53:52 +1000 Subject: [albatross-users] mod_python / RandomModularSessionApp bug In-Reply-To: Message from Paul Hart of "Sat, 14 Jun 2003 23:32:34 -0400." <00F7BEE2-9EE2-11D7-B6D0-000393CC268A@redchocolate.ca> References: <00F7BEE2-9EE2-11D7-B6D0-000393CC268A@redchocolate.ca> Message-ID: <20030617045352.D2ADC3C423@coffee.object-craft.com.au> >Whoops, so I spoke too soon; I think I have a solution. > >in apacheapp.py line 33, change the following: > > def get_servername(self): > return self.__req.connection.server.server_hostname > >into the following: > > def get_servername(self): > try: > return self.__req.connection.server.server_hostname > except: > return self.__req.hostname > >That appears to be working for me. Maybe that's been fixed in 1.10pre1; >because I want to work with release software, I haven't checked. No, it hasn't been fixed in 1.10 - we haven't tested with mod_python 3 yet. Looking at the doco, your fix seems like the right answer. Essentially, mod_python 3 has done away with the "server" member of the "connection" object (and, as you conclude, base_server is not the same thing). I'll check your change in - thanks for looking into this. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From fabbe at paniq.net Wed Jun 18 06:00:26 2003 From: fabbe at paniq.net (Fabian Fagerholm) Date: 17 Jun 2003 23:00:26 +0300 Subject: [albatross-users] Request for hints on building a complex application Message-ID: <1055880026.13276.47.camel@kernel> Hi, I'm building a large-ish application with Albatross, and I've ran into several issues. The manual has provided excellent response to some questions, but I suspect this undertaking is too complex to be answered in the manual. More experience with the toolkit is needed to explain this stuff. In short, the application is a kind of order tracking system on steroids. The back-end SQL database stores information about Products, Users and Customers. Orders are entered by the sales people and connect Products in some quantity with a Customer and some other information. In addition, Jobs performed at an hourly charge are recorded. Periodically, someone will generate entries in an Invoice table which consists of Orders and Jobs. The Invoice table entries are used to bill the Customer appropriately. I'm currently prototyping the application and I'm implementing a subset of the specification to see what problems I run into. I use ModularSessionApp and SessionAppContext. I also use mod_python. So far, I've implemented a User class that loads information from the SQL database, and updates the SQL table with changes in the destructor. There's also a rollback method to cancel any changes and a commit method to save things on demand. The attributes of a User are implemented using __getattr__ and __setattr__, so they behave like variables, but I can input-check them if needed. I've implemented a login mechanism that seems to work with the User objects. Now I'm trying to construct a user management page. The page consists of an HTML table with each user's information on separate rows. I can generate the table nicely with an tag and a list of User objects passed through the execution context to the template. But I can't seem to make the table "active". I'd like to make some table cells 's so that an administrator can simply edit the information directly and press Submit to activate all changes at once. Currently, the code snippets that do this look as follows: mgusers.py: def page_display(ctx): from Done import User ctx.locals.userlist = User.getAll() # returns a list of User obj's ctx.run_template('mgusers.html') mgusers.html: ... table begins, etc... ... submit button, table ends, form ends ... Those are only fragments but should give you an idea of what I'm trying to do. User objects have attributes uid, username, realname, password and enabled. The last four should be editable on this page. How do I accomplish this? (Feel free to ask for more details if needed.) What general advice do you have on implementing the Model classes? There's a possibility that another (gui) front-end will be added later, and I'd like to use the same Model classes for that. -- Fabian Fagerholm paniq.net -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From andrewm at object-craft.com.au Wed Jun 18 09:37:14 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 18 Jun 2003 09:37:14 +1000 Subject: [albatross-users] Request for hints on building a complex application In-Reply-To: Message from Fabian Fagerholm of "17 Jun 2003 23:00:26 +0300." <1055880026.13276.47.camel@kernel> References: <1055880026.13276.47.camel@kernel> Message-ID: <20030617233714.25ECC3CA80@coffee.object-craft.com.au> >So far, I've implemented a User class that loads information from the >SQL database, and updates the SQL table with changes in the destructor. >There's also a rollback method to cancel any changes and a commit method >to save things on demand. The attributes of a User are implemented using >__getattr__ and __setattr__, so they behave like variables, but I can >input-check them if needed. I would suggest not having a destructor (and particularly, no commiting the changes in the destructor). My experience has been that having the application explicitly commit the changes better fits the way things work (in particular, if you get an exception, you don't want inconsistent state commited to the database). A few more reasons for not defining a __del__ method are that the destructor is not guaranteed to be called (although it usually is), and cyclic garbage collection is disabled for instances of classes that define it (because the cycle breaker doesn't know what order to call the destructors in). >I've implemented a login mechanism that seems to work with the User >objects. Now I'm trying to construct a user management page. The page >consists of an HTML table with each user's information on separate rows. >I can generate the table nicely with an tag and a list of User >objects passed through the execution context to the template. But I >can't seem to make the table "active". I'd like to make some table cells >'s so that an administrator can simply edit the information >directly and press Submit to activate all changes at once. > >Currently, the code snippets that do this look as follows: > >mgusers.py: >def page_display(ctx): > from Done import User > ctx.locals.userlist = User.getAll() # returns a list of User obj's > ctx.run_template('mgusers.html') > >mgusers.html: >... table begins, etc... > > > > > > > >... submit button, table ends, form ends ... Something like: -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From djc at object-craft.com.au Wed Jun 18 10:19:40 2003 From: djc at object-craft.com.au (Dave Cole) Date: 18 Jun 2003 10:19:40 +1000 Subject: [albatross-users] Request for hints on building a complex application In-Reply-To: <1055880026.13276.47.camel@kernel> References: <1055880026.13276.47.camel@kernel> Message-ID: >>>>> "Fabian" == Fabian Fagerholm writes: Fabian> What general advice do you have on implementing the Model Fabian> classes? There's a possibility that another (gui) front-end Fabian> will be added later, and I'd like to use the same Model Fabian> classes for that. Think about building a unit test suite for the model classes. This will force you to make the code reusable, and will also allow you to think about the kind of operations you need to support in both user interfaces. - Dave -- http://www.object-craft.com.au From fabbe at paniq.net Wed Jun 18 17:18:44 2003 From: fabbe at paniq.net (Fabian Fagerholm) Date: 18 Jun 2003 10:18:44 +0300 Subject: [albatross-users] Request for hints on building a complex application In-Reply-To: <20030617233714.25ECC3CA80@coffee.object-craft.com.au> References: <1055880026.13276.47.camel@kernel> <20030617233714.25ECC3CA80@coffee.object-craft.com.au> Message-ID: <1055920723.16897.14.camel@kernel> On Wed, 2003-06-18 at 02:37, Andrew McNamara wrote: > I would suggest not having a destructor (and particularly, no commiting > the changes in the destructor). My experience has been that having the > application explicitly commit the changes better fits the way things work > (in particular, if you get an exception, you don't want inconsistent > state commited to the database). > > A few more reasons for not defining a __del__ method are that the > destructor is not guaranteed to be called (although it usually is), > and cyclic garbage collection is disabled for instances of classes that > define it (because the cycle breaker doesn't know what order to call > the destructors in). Good points. Also, the current destructor would have had to keep track of whether any changes had been made to the object, otherwise a whole bunch of unneccessary commits would have been made each time an unmodified object was destroyed. > Something like: > > > > > > > I had something similar going, but confused myself with the value() method of the iterator. However, using the above, I run into problems when Albatross is trying to merge the request into the execution context. When I submit the form, this happens: Template traceback (most recent call last): Traceback (most recent call last): File "/usr/lib/python2.2/site-packages/albatross/app.py", line 145, in run self.merge_request(ctx) File "/usr/lib/python2.2/site-packages/albatross/app.py", line 219, in merge_request ctx.merge_request() File "/usr/lib/python2.2/site-packages/albatross/context.py", line 297, in merge_request self.set_value(name, value) File "/usr/lib/python2.2/site-packages/albatross/context.py", line 323, in set_value if name[0] == '_': TypeError: unsubscriptable object Which object is it referring to? The request now has fields of the form userlist[i].attr, where i is an integer and .attr is each of the elements of my User object. Is it trying to find the first character of the list name? Also, I'm still a little confused as to what exactly is happening here. Am I storing the actual list, complete with User objects, in the session? Or am I only storing text -- ie. will I have to recreate the list and the User objects in page_process()? I guess the confusion arises because I'm actually redoing an application that has been previously (badly) implemented with Java Servlets... I suspect this is a question which comes up quite soon after you move to anything more complex than the popview application. (In particular, when you build an abstraction layer of your business logic with a transactional database as a back-end.) -- Fabian Fagerholm paniq.net -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: From matt at pollenation.net Thu Jun 19 11:11:13 2003 From: matt at pollenation.net (Matt Goodall) Date: 19 Jun 2003 02:11:13 +0100 Subject: [albatross-users] Possible bug Message-ID: <1055985073.20599.73.camel@localhost> Hi, Before I forget, I'm using 1.10pre1. I've recently been having lots of fun getting a standalone HTTP server going. In general things are going ok although I haven't done anything for file uploads yet. However, I *think* I may have found a bug when a random application is mounted as '/' on the server, as is always the case with my standalone server. In this case I would expect to set the Application's base_url to '/' or perhaps '' (zero length string) but both cause problems: * If base_url is '/' then RandomPageModuleMixin.load_page() fails as it always appends '/' to base_path. * If base_url is '' then AppContext.redirect_url() fails because new_base ends up as an empty string and so new_base[-1] raises an exception. There are a few possible solutions but I suspect the best is to ensure Application.__base_url always ends in '/' and to change RandomPageModuleMixin.load_page() so that it does not append the '/'. Hope this helps. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From tchur at optushome.com.au Thu Jun 19 01:34:13 2003 From: tchur at optushome.com.au (Tim Churches) Date: Thu, 19 Jun 2003 01:34:13 +1000 Subject: [albatross-users] Stand-alone Albatross (was: Possible bug) In-Reply-To: <1055985073.20599.73.camel@localhost> Message-ID: <000201c335af$1890fd50$a300a8c0@emilio> From: albatross-users-admin at object-craft.com.au [mailto:albatross-users- > admin at object-craft.com.au] On Behalf Of Matt Goodall > Sent: Thursday, 19 June 2003 11:11 AM > To: albatross-users at object-craft.com.au > Subject: [albatross-users] Possible bug > > Hi, > > Before I forget, I'm using 1.10pre1. > > I've recently been having lots of fun getting a standalone HTTP server > going. In general things are going ok although I haven't done anything > for file uploads yet. Fab! This is just what we require for deploying Albatross apps easily on Windows 2000 laptops (and also a native Win32 version of PostgreSQL, but that is forthcoming in version 7.4 which is nearing completion I understand). How are you implementing the HTTP server? Using the CGI Server classes in the standard Python library? Do you plan to release this code, or contribute it to Albatross? Tim C From matt at pollenation.net Thu Jun 19 19:32:55 2003 From: matt at pollenation.net (Matt Goodall) Date: Thu, 19 Jun 2003 10:32:55 +0100 Subject: [albatross-users] Stand-alone Albatross In-Reply-To: <000201c335af$1890fd50$a300a8c0@emilio> References: <000201c335af$1890fd50$a300a8c0@emilio> Message-ID: <3EF18347.1030101@pollenation.net> Tim Churches wrote: >From: albatross-users-admin at object-craft.com.au [mailto:albatross-users- > > >>admin at object-craft.com.au] On Behalf Of Matt Goodall >>Sent: Thursday, 19 June 2003 11:11 AM >>To: albatross-users at object-craft.com.au >>Subject: [albatross-users] Possible bug >> >>Hi, >> >>Before I forget, I'm using 1.10pre1. >> >>I've recently been having lots of fun getting a standalone HTTP server >>going. In general things are going ok although I haven't done anything >>for file uploads yet. >> >> > >Fab! This is just what we require for deploying Albatross apps easily on >Windows 2000 laptops Brilliant, another beta tester ... that's two of us ;-). I need it for a standalone, single user application running on Windows XP. >How are you implementing the HTTP server? Using the CGI >Server classes in the standard Python library? It is a BaseHTTPServer with a custom RequestHandler. I use the cgi module to help decode the request. I thought about using asyncore or Medusa but decided to go for the easy option first, particularly as I am not concerned with scalability and performance. >Do you plan to release this code, or contribute it to Albatross? Yes and yes. Albatross seems like the best place for it if Dave and Andrew want it in there. Dave seemed quite keen when I mentioned it in a private email but I guess it depends on whether the implementation is right for a general purpose server. It's probably fantastic for us developers anyway - no need for a bulky Apache installation (or IIS if you're unlucky). I will hopefully post it to the list soon. - Matt -- Matt Goodall, Pollenation Internet Ltd e: matt at pollenationinternet.com t: 0113 2252500 From sheila at thinkspot.net Fri Jun 20 17:31:36 2003 From: sheila at thinkspot.net (Sheila King) Date: Fri, 20 Jun 2003 00:31:36 -0700 Subject: [albatross-users] al-for and Template frustration and confusion Message-ID: <49126450.1056069096@SHEILA-LAPTOP> Oh, I'm having a bit of fun today trying to work on templates. Or, not-fun, rather. I have a navigation bar with tabs for may application, and it appears in every page, and I finally got to the point where I wanted to make it into a macro. The navbar has two different views, depending on whether the client is logged in (authenticated) or not (anonymous). And the number of tabs is different in the two versions. So, a macro with an al-for seemed like the best idea for this. My understanding of the al-for iteration is blah blah blah that iterobj, as shown above, must be some sort of object over which one can iterate. A list-type object should fit the bill here, yes? And then "i" is one object in the iterobj data-structure. Well, I have no idea why the following is failing...and I have tried a number of things, none of which has worked, but this last attempt it seemed to me SHOULD. Here is a portion of my macro, with an ** at the beginning of the problem line: ----------------------------------------- ** ...rest of macro omitted... ---------------------------------------------- Now the line ** of "Fri, 20 Jun 2003 00:31:36 MST." <49126450.1056069096@SHEILA-LAPTOP> References: <49126450.1056069096@SHEILA-LAPTOP> Message-ID: <20030620075929.E5F743C332@coffee.object-craft.com.au> >that iterobj, as shown above, must be some sort of object over which one >can iterate. A list-type object should fit the bill here, yes? And then "i" >is one object in the iterobj data-structure. I also got caught by that when I started using albatross... 8-) "i" is a ListIterator instance - it keeps track of your position in the list-like object. In particular, it has methods .value(), which returns what you are looking for, and .index() which return's it's index. I'd tell you where to look in the doco, but I only have the new version available. The information on the ListIterator object is under the tag's doco. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Sat Jun 21 06:38:53 2003 From: sheila at thinkspot.net (Sheila King) Date: Fri, 20 Jun 2003 13:38:53 -0700 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <20030620075929.E5F743C332@coffee.object-craft.com.au> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> Message-ID: <9948525.1056116333@SHEILA-LAPTOP> Thanks, Andrew, for the tips... (more below) --On Friday, June 20, 2003 5:59 PM +1000 Andrew McNamara wrote: >> that iterobj, as shown above, must be some sort of object over which one >> can iterate. A list-type object should fit the bill here, yes? And then >> "i" is one object in the iterobj data-structure. > > I also got caught by that when I started using albatross... 8-) > > "i" is a ListIterator instance - it keeps track of your position in the > list-like object. In particular, it has methods .value(), which returns > what you are looking for, and .index() which return's it's index. > > I'd tell you where to look in the doco, but I only have the new version > available. The information on the ListIterator object is under the > tag's doco. > This gave me the clue I needed to search further. The documentation did not make clear to me that, by using the al-for tag, that albatross was creating a ListIterator type that had these methods which I could use. I had to go into the source code in the tags.py file and review the ListIterator class and the code for parsing the al-for tags to "get it". I also played a bit at the command line, to further "see" for myself what is going on here. Just in case it helps someone else: H:\Python22\Albatross\albatross-1.01>python Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import albatross >>> from albatross.tags import ListIterator >>> mylist = ['a', 'b', 'c'] >>> i = ListIterator() >>> i.set_sequence(mylist) >>> dir(i) ['__doc__', '__getstate__', '__init__', '__len__', '__module__', '__setstate__', '_count', '_have_value', '_index', '_pagesize', '_seq', '_start', 'clear_value' , 'count', 'get_backdoor', 'has_nextpage', 'has_prevpage', 'has_sequence', 'has_ value', 'index', 'next', 'pagesize', 'reset_count', 'reset_index', 'set_backdoor ', 'set_pagesize', 'set_sequence', 'set_value', 'start', 'value'] >>> i.has_value() 1 >>> i.index() 0 >>> i.value() 'a' >>> i.next() >>> i.index() 1 >>> i.value() 'b' I would suggest adding some language to the docs which states that, by using the al-for tag, that albatross instantiates a ListIterator object, as defined by the class definition in the tags.py file, and that the ListIterator object will have the following methods available to it ...blah blah... Anyhow, this has given me enough of a clue to forge on a bit further. Thanks, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From matt at pollenation.net Sat Jun 21 10:00:45 2003 From: matt at pollenation.net (Matt Goodall) Date: 21 Jun 2003 01:00:45 +0100 Subject: [albatross-users] and ListIterator in current and new documentation In-Reply-To: <9948525.1056116333@SHEILA-LAPTOP> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> Message-ID: <1056153645.27189.39.camel@localhost> On Fri, 2003-06-20 at 21:38, Sheila King wrote: > I would suggest adding some language to the docs which states that, by > using the al-for tag, that albatross instantiates a ListIterator object, as > defined by the class definition in the tags.py file, and that the > ListIterator object will have the following methods available to it ...blah > blah... Sorry to disagree but I think the current documentation is reasonably clear. The iter attribute is described as "... the name of the ListIterator (5.3.7.8) ...". ListIterator is also described in the section. More importantly ... I read the documentation from the 1.10pre1 distribution and I would say that the new documentation is less clear on this matter than the 1.0.1 version. The 2nd paragraph of section 5.3.7 would be an ideal place to mention the ListIterator. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From neel at mediapulse.com Mon Jun 23 08:51:22 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Sun, 22 Jun 2003 18:51:22 -0400 Subject: [albatross-users] Trying to work around pagnation with cols issue... Message-ID: Currently Albatross doesn't support pagesize and cols in the same al-for tag, and I'm trying towork around this by grouping my results into cols and using two al-for tags for the output. It's not working, and I'm not sure why. Here is the page_process for the section I'm testing with: photos = ['One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] ctx.locals.photos = [] # We now must make ctx.locals.photos be a list of (up to) 3 element lists of photos # this is because albatross doesnot support pagnation with a cols attrib temp = [] for pht in photos: temp.append(pht) if len(temp) == 3: ctx.locals.photos.append(temp[:]) # [:] is an explict copy temp = [] if len(temp): ctx.locals.photos.append(temp[:]) # [:] is an explict copy And then in my template file:
The next button does appear, but clicking it doesn't advance to the next page. Thanks in advance, Mike From matt at pollenation.net Mon Jun 23 10:42:31 2003 From: matt at pollenation.net (Matt Goodall) Date: 23 Jun 2003 01:42:31 +0100 Subject: [albatross-users] Trying to work around pagnation with cols issue... In-Reply-To: References: Message-ID: <1056328951.2872.45.camel@localhost> On Sun, 2003-06-22 at 23:51, Michael C. Neel wrote: > Currently Albatross doesn't support pagesize and cols in the same al-for > tag, and I'm trying towork around this by grouping my results into cols > and using two al-for tags for the output. It's not working, and I'm not > sure why. > > Here is the page_process for the section I'm testing with: > > photos = > ['One','Two','Three','Four','Five','Six','Seven','Eight','Nine'] > ctx.locals.photos = [] > # We now must make ctx.locals.photos be a list of (up to) 3 > element lists of photos > # this is because albatross doesnot support pagnation with a > cols attrib > temp = [] > for pht in photos: > temp.append(pht) > if len(temp) == 3: > ctx.locals.photos.append(temp[:]) # [:] is an > explict copy > temp = [] > if len(temp): > ctx.locals.photos.append(temp[:]) # [:] is an explict > copy A slightly nicer way of writing this might be: photos = [...] ctx.locals.photos = [] i = 0 while 1: row = photos[i:i+3] if not row: break ctx.locals.photos.append(row) i = i+3 But that wasn't the question ;-) > > And then in my template file: > > > > > > > > > > >
>
> > > > > > >
> > name="photo_prev"> > > > > name="photo_next"> > >
> > The next button does appear, but clicking it doesn't advance to the next > page. Hmm. I can't see anything wrong. I've tried the above code here and it works ok with Albatross 1.10pre1. The name="photo_prev" and name="photo_next" attributes are redundant since they are generated by the tag but that doesn't seem to matter. What type of app (stateful/random, session in form/file/server etc) are you writing and what version of Albatross are you using? - Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net From matt at pollenation.net Mon Jun 23 11:17:00 2003 From: matt at pollenation.net (Matt Goodall) Date: 23 Jun 2003 02:17:00 +0100 Subject: [albatross-users] Standalone HTTP Albatross server Message-ID: <1056331020.29342.79.camel@localhost> Hi, Attached is the first cut at a simple, standalone HTTP server script for Albatross apps. It's been written for 1.10pre1 although there seems to be a bug in that version which stops it actually working. See my post of 19 Jun 2003 for more on the bug and a possible solution. The script is working ok for me but it has only had minimal testing and has some known limitations: * No file upload support. I will try to sort that out soon. * It uses the standard BaseHTTPServer module so it's not much more that a toy. It's ok for local development and as a very low use server i.e. for single user, web-based apps. I'm posting this now in the hope that it is useful in its current form (i.e. without file upload) and maybe to get some feedback. "So how do I use it?", I hear you all ask. The easiest way is to run the httpd.py script with the name of the App class and the port as the only arguments. For instance: python httpd.py test.App 8080 would import the 'test' module, create an instance of the 'App' class and run an HTTP server on port 8080. Dave, Andrew - as I previously mentioned, this is all yours if you want it but it's never going to perform well. An asyncore/Medusa/Twisted implementation would almost certainly be better but I don't have time for those right now ... sorry. Cheers, Matt -- Matt Goodall Pollenation Internet Ltd, http://www.pollenation.net e: matt at pollenation.net -------------- next part -------------- A non-text attachment was scrubbed... Name: httpd.py Type: text/x-python Size: 3846 bytes Desc: not available URL: From neel at mediapulse.com Tue Jun 24 00:21:39 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 23 Jun 2003 10:21:39 -0400 Subject: [albatross-users] Trying to work around pagnation with colsissue... Message-ID: > A slightly nicer way of writing this might be: > > photos = [...] > ctx.locals.photos = [] > i = 0 > while 1: > row = photos[i:i+3] > if not row: break > ctx.locals.photos.append(row) > i = i+3 > > But that wasn't the question ;-) > I've been trying to adopt the python "feeling" that i's are bad and not needed. My days as a C programmer reach for the C for loop (which is what this really is, for(i=0, 1; i++)) but then I say no I should do it without that because it's not the python way. Now I find the above a lot harder to read, lol. > > What type of app (stateful/random, session in > form/file/server etc) are > you writing and what version of Albatross are you using? > SimpleApp; Apache 1.3x; mod_python. Using pagnation all over the place, and for some odd reason this is the only one breaking. I haven't gone to the pre-release because I have several Albatross sites on the server so upgrading will be a real pain. Is there some way to install it as a different name; i.e. albatrosspre110 so I could have it side by side with 1.01? I tried installing it in the modules folder with the app, but mod_python doesn't seem to wanna change the path order (it will work command line, importing the right one, but not under mod_python). Mike From esj at harvee.org Tue Jun 24 06:33:44 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 23 Jun 2003 16:33:44 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: <3EF76428.70000@harvee.org> I am a (very) new user of albatross and so far I'm reasonably impressed. I'm quite the curmudgeon when it comes to tools like albatross and I've rejected most of them because they were either too primitive or too heavy. "I'm rewriting the camram (antispam) Web interface using albatross because at 3 CGI's, I was %s in some %s duplication and % of HTML and print statements." %("engaged", "horrible", "messes") albatross looked like a good tool so, I'm giving it a whirl and rewriting the first interface. Unfortunately, I've hit a cognitive snag on one of the first difficult points. First question is if I'm displaying a two-dimensional array of data and input mechanisms, is there any "official" way of doing this. I've built a list of a list and within the template, use a loop to pull elements of of the parent list and then decompose the element into its component pieces using simple indexing (i.e. . This technique seems rather awkward but I'm trying to make it work the best I can. Second question is on the addition of JavaScript and style sheet elements to HTML tags. Specifically, I need to create a check box that looks like (and yes, I do use the value and name): I am comfortable with mungohacking html if need be, I just need to know if I need to. --- eric From neel at mediapulse.com Tue Jun 24 06:47:30 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 23 Jun 2003 16:47:30 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: > "I'm rewriting the camram (antispam) Web interface using > albatross because at 3 > CGI's, I was %s in some %s duplication and % of HTML and > print statements." > %("engaged", "horrible", "messes") Traceback (most recent call last): File "", line 3, in ? ValueError: incomplete format Sorry... couldn't resist... Mike From neel at mediapulse.com Tue Jun 24 06:53:59 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 23 Jun 2003 16:53:59 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: > First question is if I'm displaying a two-dimensional > array of data and input > mechanisms, is there any "official" way of doing this. > I've built a list of a > list and within the template, use a loop to > pull elements of of the > parent list and then decompose the element into its > component pieces using > simple indexing (i.e. . > This technique seems > rather awkward but I'm trying to make it work the best I can. I prefer to use an al-exec to get friendly names, such as: If things are more complex I build an array of objects, and pull them out as such: > Second question is on the addition of JavaScript and > style sheet elements to Not really up on JS and CSS to help here From neel at mediapulse.com Tue Jun 24 06:54:41 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 23 Jun 2003 16:54:41 -0400 Subject: [albatross-users] Trying to work around pagnation with colsissue... Message-ID: Ignore this; turns out I had an iter="row" hidden away in a macro causing a problem with this one. Odd that I was allowed to do that when one was in page mode the other not. Thanks, Mike > -----Original Message----- > From: Michael C. Neel > Sent: Monday, June 23, 2003 10:22 AM > To: albatross-users at object-craft.com.au > Subject: RE: [albatross-users] Trying to work around > pagnation with colsissue... > > > > A slightly nicer way of writing this might be: > > > > photos = [...] > > ctx.locals.photos = [] > > i = 0 > > while 1: > > row = photos[i:i+3] > > if not row: break > > ctx.locals.photos.append(row) > > i = i+3 > > > > But that wasn't the question ;-) > > > > I've been trying to adopt the python "feeling" that i's > are bad and not > needed. My days as a C programmer reach for the C for > loop (which is > what this really is, for(i=0, 1; i++)) but then I say no > I should do it > without that because it's not the python way. Now I > find the above a > lot harder to read, lol. > > > > > What type of app (stateful/random, session in > > form/file/server etc) are > > you writing and what version of Albatross are you using? > > > SimpleApp; Apache 1.3x; mod_python. Using pagnation all > over the place, > and for some odd reason this is the only one breaking. > > I haven't gone to the pre-release because I have several > Albatross sites > on the server so upgrading will be a real pain. Is > there some way to > install it as a different name; i.e. albatrosspre110 so > I could have it > side by side with 1.01? I tried installing it in the > modules folder > with the app, but mod_python doesn't seem to wanna > change the path order > (it will work command line, importing the right one, but > not under > mod_python). > > Mike > _______________________________________________ > Albatross-users mailing list > Albatross-users at object-craft.com.au > https://www.object-craft.com.au/cgi-bin/mailman/listinfo/ albatross-users From esj at harvee.org Tue Jun 24 07:04:56 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 23 Jun 2003 17:04:56 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data In-Reply-To: References: Message-ID: <3EF76B78.5010703@harvee.org> Michael C. Neel wrote: > I prefer to use an al-exec to get friendly names, such as: > > > > > > If things are more complex I build an array of objects, and pull them > out as such: > > > > this is great. This is the kind of thing that should be in a helpful hints/best practices/cookbook section of the documentation. question: does the lval names get put into the context.local. namespace or are they in their own namespace? I'm worried about overwriting data on trying to bring into the template. > > > Second question is on the addition of JavaScript and > > style sheet elements to > > Not really up on JS and CSS to help here don't need to be (but you should for style sheets. Dammed powerful). Let's look at the original source again: ostensibly, I would use a so the question becomes how do I fit in my "onclick..." statement. It is albatross sufficiently clever that if it encounters a field it doesn't recognize, it just passes it through to the HTML? ---eric From neel at mediapulse.com Tue Jun 24 07:49:50 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Mon, 23 Jun 2003 17:49:50 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: > question: does the lval names get put into the > context.local. namespace or > are they in their own namespace? I'm worried about > overwriting data on trying > to bring into the template. Vars in the template are all in the ctx.locals namespace; which is also merged with the request. If you have some vars you don't want to be messed with by the request, prefix them with an _ (i.e. ctx.locals._username) so they can't be hacked with. > don't need to be (but you should for style sheets. > Dammed powerful). Let's look > at the original source again: I work with some good designers who know the client side stuff really well so they usally just give me the JS/CSS code ;) > ostensibly, I would use a > so the question becomes > how do I fit in my "onclick..." statement. It is > albatross sufficiently clever > that if it encounters a field it doesn't recognize, it > just passes it through to > the HTML? Yes, any attrib albatross doesn't handel or need to change it just passed though; so id, name, onchange, etc will all work. Mike From esj at harvee.org Tue Jun 24 08:37:15 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 23 Jun 2003 18:37:15 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data In-Reply-To: References: Message-ID: <3EF7811B.70007@harvee.org> Michael C. Neel wrote: > I work with some good designers who know the client side stuff really > well so they usally just give me the JS/CSS code ;) ;-) I've tried that an occasion but what I want to do makes most designers whimper with fear. > Yes, any attrib albatross doesn't handel or need to change it just > passed though; so id, name, onchange, etc will all work. I eventually just went to the straight input tag with sprinkled liberally about. I've gotten tired of looking at the: ApplicationError: al-input "checkbox_name" not defined as "list" type errors today. I will figure out why I get these love notes later. many thanks for help. ---eric From djc at object-craft.com.au Tue Jun 24 11:23:59 2003 From: djc at object-craft.com.au (Dave Cole) Date: 24 Jun 2003 11:23:59 +1000 Subject: [albatross-users] displaying two-dimensional arrays of data In-Reply-To: <3EF76B78.5010703@harvee.org> References: <3EF76B78.5010703@harvee.org> Message-ID: > Michael C. Neel wrote: > > I prefer to use an al-exec to get friendly names, such as: > > > > > > I tend not to use two dimensional arrays if I can avoid them. I just build single dimensional arrays of attribute only objects. If makes the code much more readable. > > If things are more complex I build an array of objects, and pull them > > out as such: > > > > > > > > this is great. This is the kind of thing that should be in a helpful > hints/best practices/cookbook section of the documentation. > > question: does the lval names get put into the context.local. > namespace or are they in their own namespace? I'm worried about > overwriting data on trying to bring into the template. It all happens in the local namespace. In Python assignments to variables happen in the local namespace unless you declare a name to be global. Albatross uses this nice feature to provide a local and global namespace. The templating system uses ctx.locals.__dict__ as the local namespace in expressions and the globals of the function that ran the template as the global namespace. You can see this happening in the following: >>> import albatross >>> def templ(ctx, text): ... albatross.Template(ctx, '', text).to_html(ctx) ... >>> ctx = albatross.SimpleContext('.') >>> templ(ctx, '') >>> ctx.locals.a 3 >>> templ(ctx, '') >>> a 4 - Dave -- http://www.object-craft.com.au From neel at mediapulse.com Tue Jun 24 23:32:56 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 24 Jun 2003 09:32:56 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: > I eventually just went to the straight input tag with > sprinkled > liberally about. I've gotten tired of looking at the: > > ApplicationError: al-input "checkbox_name" not defined as "list" > Mike From neel at mediapulse.com Tue Jun 24 23:34:50 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 24 Jun 2003 09:34:50 -0400 Subject: [albatross-users] displaying two-dimensional arrays of data Message-ID: > I tend not to use two dimensional arrays if I can avoid > them. I just > build single dimensional arrays of attribute only > objects. If makes > the code much more readable. > Heh, tell that to my DB cursor... Mike From esj at harvee.org Tue Jun 24 23:59:41 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 24 Jun 2003 09:59:41 -0400 Subject: [albatross-users] (more sweet mysteries of life Message-ID: <3EF8594D.3070801@harvee.org> I was puzzling over why why does: generate: sort_order and on_top are defined and I would have expected a name and value field for the submit button. in playing around, I simplified it to: and accepted that the button name is constant. Any state information will be handled by a separate hidden variable. However, I still need to value to change because the label of the button changes telling the user importance date information. reading the fine manual, I come to find out that valueexpr is ignored for anything other than radio buttons and checkboxes. I tried a couple of tricks with al-value but haven't found anything to work right. It's beginning to look like I cannot do a simple variable substitution for the value field argument. Any pointers or ideas? I'm currently looking at a if statements with replicated HTML inside changing only one field. I also request that this restriction be lifted and valueexpr should be recognized anywhere the HTML value attribute is. ---eric From esj at harvee.org Wed Jun 25 03:31:23 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 24 Jun 2003 13:31:23 -0400 Subject: [albatross-users] setting value field Message-ID: <3EF88AEB.5020601@harvee.org> over the past couple of days, you ever patient folks have seen me butt my head against various parts of albatrosson. Here's another one. In the Web interface, I use multiple buttons to trigger different events. One button toggles sorting order (ascending/descending), another triggers the process for training which messages or spam or not spam. The only button I do anything fancy with is the sorting order button. Originally, I changed the value of the button to reflect the sorting order and used the value of the button as state information when toggling to the other sort. Since the tag doesn't seem to support variable values except in special circumstances, I'm a bit hosed. I'm also trying to puzzle out how to deal with page initial state versus page after processing button results. So far, I'm some some context.local variables that come and go depending on whether or not it's the first time through the page templates. puzzled but still persisting, ---eric From sheila at thinkspot.net Wed Jun 25 03:39:25 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 24 Jun 2003 10:39:25 -0700 Subject: [albatross-users] (more sweet mysteries of life In-Reply-To: <3EF8594D.3070801@harvee.org> References: <3EF8594D.3070801@harvee.org> Message-ID: <13123420.1056451165@SHEILA-LAPTOP> OMG. A question *I* can answer (instead of just asking questions all the time). See below: --On Tuesday, June 24, 2003 9:59 AM -0400 "Eric S. Johansson" wrote: > reading the fine manual, I come to find out that valueexpr is ignored for > anything other than radio buttons and checkboxes. I tried a couple of > tricks with al-value but haven't found anything to work right. It's > beginning to look like I cannot do a simple variable substitution for > the value field argument. Any pointers or ideas? Try this: where myvalue is some al-value type of thing you want (like a ctx.locals.myvalue type of expression, but omit ctx.locals, as that is understood within the tags). Here's an example tag from my own application: _client is an instance of a class that has attribute emails (an Email class) with attribute email1 (which is a string type). This inserts the pre-existing value of email1 into the form's input element for me. HTH, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From neel at mediapulse.com Wed Jun 25 04:55:54 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Tue, 24 Jun 2003 14:55:54 -0400 Subject: [albatross-users] setting value field Message-ID: In my apps I use the name of the submit button to control flow, using the ctx.req_equals(). Normally looks something like: if self.page = "mystuff/form.html": if ctx.req_equals("saveme"): #save the record elif ctx.req_equals("delme"): # delete the record etc.... Note: if you us images for sumbit buttons, then you nees to do ctx.req_equals("saveme.x") - I'm not sure if that's still true in 1.10pre1 As for setting values in an al-input; you don't need to do anything. If ctx.locals.name = 'Mike', and your tag is albatross will write out . Mike From sholden at holdenweb.com Wed Jun 25 08:13:09 2003 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 24 Jun 2003 18:13:09 -0400 Subject: [albatross-users] Documentation bug Message-ID: On both the albatross web documentation and the downloadable stuff, all the "download as text" links point to the same file, which isn't very helpful. See, for example, http://object-craft.com.au/projects/albatross/albatross/tug-simple3.html . Someone should fix this before the next release. Hi, Dave. regards -- Steve Holden http://www.holdenweb.com/ Python Web Programming http://pydish.holdenweb.com/pwp/ From djc at object-craft.com.au Wed Jun 25 10:23:51 2003 From: djc at object-craft.com.au (Dave Cole) Date: 25 Jun 2003 10:23:51 +1000 Subject: [albatross-users] Documentation bug In-Reply-To: References: Message-ID: >>>>> "Steve" == Steve Holden writes: Steve> On both the albatross web documentation and the downloadable Steve> stuff, all the "download as text" links point to the same file, Steve> which isn't very helpful. See, for example, Steve> http://object-craft.com.au/projects/albatross/albatross/tug-simple3.html Steve> . Someone should fix this before the next release. The problem was caused by a "bug" in the latex2html extensions in the Python Doc directory. I reported this some time ago - it looks like it has been fixed in 2.3. I will rebuild all of the documentation with Python 2.3 and reinstall. Still having funny problems with PNG image generation on this machine... Steve> Hi, Dave. Hi there. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Wed Jun 25 11:16:53 2003 From: djc at object-craft.com.au (Dave Cole) Date: 25 Jun 2003 11:16:53 +1000 Subject: [albatross-users] displaying two-dimensional arrays of data In-Reply-To: References: Message-ID: >>>>> "Michael" == Michael C Neel writes: >> I tend not to use two dimensional arrays if I can avoid them. I >> just build single dimensional arrays of attribute only objects. If >> makes the code much more readable. >> Michael> Heh, tell that to my DB cursor... Check this out: http://opensource.theopalgroup.com/ The dbrow module might be exactly what you need. - Dave -- http://www.object-craft.com.au From sheila at thinkspot.net Wed Jun 25 12:53:04 2003 From: sheila at thinkspot.net (Sheila King) Date: Tue, 24 Jun 2003 19:53:04 -0700 Subject: [albatross-users] setting value field In-Reply-To: References: Message-ID: <46341916.1056484384@SHEILA-LAPTOP> --On Tuesday, June 24, 2003 2:55 PM -0400 "Michael C. Neel" wrote: > In my apps I use the name of the submit button to control flow, using > the ctx.req_equals(). > > Normally looks something like: > > if self.page = "mystuff/form.html": > > if ctx.req_equals("saveme"): > #save the record > elif ctx.req_equals("delme"): > # delete the record > etc.... > > Note: if you us images for sumbit buttons, then you nees to do > ctx.req_equals("saveme.x") - I'm not sure if that's still true in > 1.10pre1 It is interesting to see how different people are handling these types of things. I've just been doing something like this: if ctx.has_value('submit'): # do the submit stuff elif ctx.has_value('cancel'): # do the cancel stuff etc... Where 'submit' or 'cancel' or what have you is the name of the submit-type form element. I don't see any downside to this technique? -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From esj at harvee.org Wed Jun 25 13:40:08 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 24 Jun 2003 23:40:08 -0400 Subject: [albatross-users] setting value field In-Reply-To: References: Message-ID: <3EF91998.1010400@harvee.org> Michael C. Neel wrote: > In my apps I use the name of the submit button to control flow, using > the ctx.req_equals(). > > Normally looks something like: > > if self.page = "mystuff/form.html": > > if ctx.req_equals("saveme"): > #save the record > elif ctx.req_equals("delme"): > # delete the record > etc.... ah. more missing pieces are falling into place. > As for setting values in an al-input; you don't need to do anything. If > ctx.locals.name = 'Mike', and your tag is name="name"> albatross will write out value="Mike">. so you are saying that the value of the name used for the name field is applied to the value field. It's marvelously simple and quite intuitive once you know it's there!! is this documented anywhere? I would love to know where my brain skiped the groove. more questions tomorrow as I puzzle out the joys of state preservation ---eric From esj at harvee.org Wed Jun 25 13:43:13 2003 From: esj at harvee.org (Eric S. Johansson) Date: Tue, 24 Jun 2003 23:43:13 -0400 Subject: [albatross-users] (more sweet mysteries of life In-Reply-To: <13123420.1056451165@SHEILA-LAPTOP> References: <3EF8594D.3070801@harvee.org> <13123420.1056451165@SHEILA-LAPTOP> Message-ID: <3EF91A51.5050407@harvee.org> Sheila King wrote: > OMG. A question *I* can answer (instead of just asking questions all the > time). See below: thanks for the example. It's been a long time since I've been on the other side of the fence (I'm usually answering questions). However, the past year has been the time for covering new ground hence lots of questions. ---eric From matt at pollenation.net Wed Jun 25 19:51:06 2003 From: matt at pollenation.net (Matt Goodall) Date: Wed, 25 Jun 2003 10:51:06 +0100 Subject: [albatross-users] setting value field In-Reply-To: <3EF91998.1010400@harvee.org> References: <3EF91998.1010400@harvee.org> Message-ID: <3EF9708A.50806@pollenation.net> Eric S. Johansson wrote: > Michael C. Neel wrote: > >> As for setting values in an al-input; you don't need to do anything. If >> ctx.locals.name = 'Mike', and your tag is > name="name"> albatross will write out > value="Mike">. > > > so you are saying that the value of the name used for the name field > is applied to the value field. Yes, in its simplest form it simply looks up the value in the ctx.locals. > It's marvelously simple and quite intuitive once you know it's there!! Lovely isn't it :). The simplicity of the really common (and often tedious) stuff is one of the things that made me look at Albatross. > is this documented anywhere? I would love to know where my brain > skiped the groove. It is, although it took me a while to find it again ;-). The 2nd paragraph of section 5.2.2 is the important bit; "execution context" simply means ctx.locals here. To summarise, it goes something like this: 1. if the 'expr' attribute is present then evaluate the expression and use the result as the value 2. else if the 'value' attribute is present then use it as the value 3. else use the 'name' attribute to look up the value in the ctx.locals Don't forget that the code is all there on your disk and most of it is very simple to read. FYI, all the HTML tag support is in tags.py, just search for 'al-input' or 'al-for' etc to find the code. Isn't open source wonderful :). -- Matt Goodall, Pollenation Internet Ltd e: matt at pollenationinternet.com t: 0113 2252500 From neel at mediapulse.com Thu Jun 26 00:06:59 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Wed, 25 Jun 2003 10:06:59 -0400 Subject: [albatross-users] setting value field Message-ID: > I've just been doing something like this: > > if ctx.has_value('submit'): > # do the submit stuff > elif ctx.has_value('cancel'): > # do the cancel stuff > > etc... > > Where 'submit' or 'cancel' or what have you is the name > of the submit-type > form element. > > I don't see any downside to this technique? The difference between req_equals and has_value is slight, but can catch you off guard. for req_equals to be true there must exists that name in the ctx.lcoals AND it must have been submitted in the last request. has_value checks is true only if the name exists in the ctx.locals namespace. So has_value can come from stored session data; req_equals must be in the form. You're probably not going to do a ctx.add_session_vars('submit'), so in pratice they can both be used for this kind of work. Mike From esj at harvee.org Thu Jun 26 09:30:56 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 25 Jun 2003 19:30:56 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: References: Message-ID: <3EFA30B0.7020206@harvee.org> in current camram spamtrap user interface, each row contains a check box. The check box has a unique name and value and is checked or unchecked based on a score. The name and value is based on the spamtrap ID. the users work task is to correct the assessment of whether or not the messages spam. In processing the users feedback, use the checkbox state (checked or unchecked) to tell me how to process what is in the value field. I use the value field to tell me what to process (i.e. which message). I'm having trouble doing this within the boundaries of albatross. The documentation hints at the ability to group checkbox items into a list but I'm not sure if it will give me both checked and unchecked information. in summary, I need to figure out how to: associate data with a checkbox explicitly set the state return the data with a checkbox data (check or unchecked) I think I'm partway there yields: seems okay except for the checkbox. I could probably generate checkbox if I assigned the value of spamtrap_token to retrain_list but that strikes me as an odd way to approach the problem. as for getting a list of which fields were checked off, I find that there is a context variable created using the name from the name field: Jun 25 19:20:45 harvee python2: retrain_list = ['fd18bcd1a7363142', '35e22ff9b3523135', '64854d86b4dc81ef'] I'm still unclear on how to get a list of what isn't checked off. FYI, the reason I just can't go back to the original source is because it's always changing as more spam comes in. Storing all the information in a hidden field is possible but unpleasant to contemplate. on handling button presses, I'm grateful for Mike's suggestion of using req_equals to determine when buttons have been pressed as well as the subsequent discussion on the pros and cons for various techniques. wait till I start tackling something really difficult ;-) ---eric From gnb at itga.com.au Thu Jun 26 09:53:24 2003 From: gnb at itga.com.au (Gregory Bond) Date: Thu, 26 Jun 2003 09:53:24 +1000 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: Your message of Wed, 25 Jun 2003 19:30:56 -0400. Message-ID: <200306252353.JAA07631@lightning.itga.com.au> This is one of the things albatross does really well. In your template, something like this: Then in your page_process function, you can do for l in ctx.locals.ignorelist: # use the selected value l I.e. the value of each selected checkbox is made available in the ctx.locals variable which is a vector with the same name=<> as the checkbox. Greg. From andrewm at object-craft.com.au Thu Jun 26 10:46:43 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 26 Jun 2003 10:46:43 +1000 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: Message from "Eric S. Johansson" of "Wed, 25 Jun 2003 19:30:56 -0400." <3EFA30B0.7020206@harvee.org> References: <3EFA30B0.7020206@harvee.org> Message-ID: <20030626004643.80FFA3C426@coffee.object-craft.com.au> >I'm still unclear on how to get a list of what isn't checked off. FYI, the >reason I just can't go back to the original source is because it's always >changing as more spam comes in. Storing all the information in a hidden field >is possible but unpleasant to contemplate. One way or another you will have to carry the list of "unchecked" boxes across. Some options include: - putting the full list into the execution context (ctx.locals), provided you're using a stateful application model. - putting the full list into a hidden field - I'm not sure why you suggest this is unpleasant - it's quite easy to do, and it will work with the non-stateful application model. - using separate names for each checkbox via the nameexpr attribute. You might implement the last one like this (note - untested): Page module (or page class with some modifications): class SpamtrapTokens: def __init__(self, token_list): self.token_list = [] for token in token_list: token_attr = 't_' + token setattr(self, token_attr, 'on') self.token_list.append(token_attr) def selected(self): return [attr for attr in self.token_list if getattr(self, attr) == 'on'] def unselected(self): return [attr for attr in self.token_list if getattr(self, attr) == ''] def page_enter(ctx): ctx.locals.spamtrap_tokens = SpamtrapTokens( ... ) Template: ...
-- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From esj at harvee.org Thu Jun 26 11:22:31 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 25 Jun 2003 21:22:31 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: <20030626004643.80FFA3C426@coffee.object-craft.com.au> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> Message-ID: <3EFA4AD7.9010608@harvee.org> Andrew McNamara wrote: > One way or another you will have to carry the list of "unchecked" > boxes across. when I use straight HTML, I don't have to. It's possible to encode all the information in the name and value fields such that you can extract a list of checked and unchecked entries in a single pass. > Some options include: > > - putting the full list into the execution context (ctx.locals), provided > you're using a stateful application model. > - putting the full list into a hidden field - I'm not sure why you suggest > this is unpleasant - it's quite easy to do, and it will work with the > non-stateful application model. > - using separate names for each checkbox via the nameexpr attribute. thanks for the options. I'm probably going to try something like the last one although I am having troubles with names. I considered the full list in a hidden variable unpleasant because at some point, you run out of room and you really don't know where that limit is. Each entry is 16 characters long not including separator and it's possible for the user to configure the system so that there are a few hundred entries visible on the screen. It wouldn't be wise but they can do it. At what point does a hidden variable run out of room and how does that manifest? Are the limits the same for all browsers? Therefore, I prefer less fragile options. what I used to do was stick a prefix in front of each spamtrap token and make that the name. The value would be the spamtrap token. After they submit button press, I would look through all the returned values for the prefix and check for the checked or unchecked state. I was hoping for something equivalently simple. I like your idea of using separate names that you detailed. As I stated above, I'm having trouble with names and it looks a little weird. For example, I have a simple variable called "spamtrap_token" and it looks like this: 6212922bbc33af37 if I refer to it simply as """", line 1 6212922bbc33af37 ^ SyntaxError: unexpected EOF while parsing since it's just a string, it doesn't have a value method and albatross is not afraid to tell me so. thank you for your suggestions, I'll will play with them and see what happens. ---eric From andrewm at object-craft.com.au Thu Jun 26 11:48:33 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 26 Jun 2003 11:48:33 +1000 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: Message from "Eric S. Johansson" of "Wed, 25 Jun 2003 21:22:31 -0400." <3EFA4AD7.9010608@harvee.org> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> Message-ID: <20030626014833.230F73C426@coffee.object-craft.com.au> >> One way or another you will have to carry the list of "unchecked" >> boxes across. > >when I use straight HTML, I don't have to. It's possible to encode all the >information in the name and value fields such that you can extract a list of >checked and unchecked entries in a single pass. That's still possible - essentially that's what you're using in option 3, although my example went further, by using the namespace merging. BTW, in my example, the should be: >thanks for the options. I'm probably going to try something like the last >one although I am having troubles with names. I considered the full list >in a hidden variable unpleasant because at some point, you run out of room >and you really don't know where that limit is. Each entry is 16 >characters long not including separator and it's possible for the user to >configure the system so that there are a few hundred entries visible on >the screen. It wouldn't be wise but they can do it. At what point does a >hidden variable run out of room and how does that manifest? Are the >limits the same for all browsers? Therefore, I prefer less fragile >options. The HiddenField session mixin store the application context in a hidden input field. I've regularly used this with many kilobytes in the context with a number of browsers (IE 5.5, IE 6, Mozilla 1.0, Opera, etc, albeit all modern browsers - I've given up on Netscape 4 aged rendering model and security problems). >what I used to do was stick a prefix in front of each spamtrap token and >make that the name. The value would be the spamtrap token. After they >submit button press, I would look through all the returned values for the >prefix and check for the checked or unchecked state. I was hoping for >something equivalently simple. Essentially, you're just after a boolean checked/unchecked value for each token, yes? You don't need to do anything as complex as setting the input value to the token, as well as having the token in the name - a simple value="on" should be enough. >I like your idea of using separate names that you detailed. As I stated >above, I'm having trouble with names and it looks a little weird. For >example, I have a simple variable called "spamtrap_token" and it looks >like this: 6212922bbc33af37 if I refer to it simply as """type="checkbox" name="spamtrap_token" """ the name is not translated. If >I instead refer to it as """nameexpr="spamtrap_token" """ I get an error stating: > > return eval(name, {}, self.locals.__dict__) > File "", line 1 > 6212922bbc33af37 > ^ >SyntaxError: unexpected EOF while parsing What's happening here is the nameexpr is being evaluated to yield the name of '6212922bbc33af37', which is then evaluated again to get to input value (which is where the exception is raised). You could prepend something to the token (as you suggest earlier) to make it a valid python expression (albeit one that raises an AttributeError, which is ignored by albatross): Setting an explict value="on" attribute will also prevent the error. The rules and relationships between name, nameexpr, value and valueexpr are really too complex for meer mortals (me included). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From esj at harvee.org Thu Jun 26 12:01:17 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 25 Jun 2003 22:01:17 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: <20030626014833.230F73C426@coffee.object-craft.com.au> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> <20030626014833.230F73C426@coffee.object-craft.com.au> Message-ID: <3EFA53ED.306@harvee.org> Andrew McNamara wrote: > That's still possible - essentially that's what you're using in option 3, > although my example went further, by using the namespace merging. and I'm trying to puzzle it out ;-) > BTW, in my example, the should be: > > nameexpr="'spamtrap_tokens.' + token_i.value()"> I'll need to think about this one when I'm more awake (gmt-4 here and I am up a bit past my bedtime). > The HiddenField session mixin store the application context in a hidden > input field. I've regularly used this with many kilobytes in the context > with a number of browsers (IE 5.5, IE 6, Mozilla 1.0, Opera, etc, albeit > all modern browsers - I've given up on Netscape 4 aged rendering model > and security problems). fair enough. That might make it a viable option then >>what I used to do was stick a prefix in front of each spamtrap token and >>make that the name. The value would be the spamtrap token. After they >>submit button press, I would look through all the returned values for the >>prefix and check for the checked or unchecked state. I was hoping for >>something equivalently simple. > > > Essentially, you're just after a boolean checked/unchecked value for > each token, yes? You don't need to do anything as complex as setting > the input value to the token, as well as having the token in the name - > a simple value="on" should be enough. yes basically all I care about is being able to set the checkbox state (on/off) and to retrieve the token and the checkbox state. > What's happening here is the nameexpr is being evaluated to yield the name > of '6212922bbc33af37', which is then evaluated again to get to input value > (which is where the exception is raised). > > You could prepend something to the token (as you suggest earlier) to make > it a valid python expression (albeit one that raises an AttributeError, > which is ignored by albatross): > > > > Setting an explict value="on" attribute will also prevent the error. OK, since I'm giving everything else a shot, I might as well try this. > The rules and relationships between name, nameexpr, value and valueexpr > are really too complex for meer mortals (me included). so I've gathered... ---eric From esj at harvee.org Thu Jun 26 12:26:55 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 25 Jun 2003 22:26:55 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: <20030626014833.230F73C426@coffee.object-craft.com.au> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> <20030626014833.230F73C426@coffee.object-craft.com.au> Message-ID: <3EFA59EF.2090601@harvee.org> Andrew McNamara wrote: > You could prepend something to the token (as you suggest earlier) to make > it a valid python expression (albeit one that raises an AttributeError, > which is ignored by albatross): > > > > Setting an explict value="on" attribute will also prevent the error. > > The rules and relationships between name, nameexpr, value and valueexpr > are really too complex for meer mortals (me included). just a brief note on this and then it's off to bed. name should've been namexpr. name gives me: it's an interesting form but not what I wanted. On the other hand nameexpr yields which is something I can live with now all I'm left with figuring out is how to turn on or off the checkbox (and maybe how to retrieve data... ;-) ---eric From andrewm at object-craft.com.au Thu Jun 26 12:46:12 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 26 Jun 2003 12:46:12 +1000 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: Message from "Eric S. Johansson" of "Wed, 25 Jun 2003 22:26:55 -0400." <3EFA59EF.2090601@harvee.org> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> <20030626014833.230F73C426@coffee.object-craft.com.au> <3EFA59EF.2090601@harvee.org> Message-ID: <20030626024612.A03083C426@coffee.object-craft.com.au> >name should've been namexpr. name gives me: > >name="'token'+spamtrap_token" value="on"> > >it's an interesting form but not what I wanted. On the other hand >nameexpr yields > >name="tokenf2952773fad60176" value="on"> Ah yes - I missed picking this up... 8-) >now all I'm left with figuring out is how to turn on or off the checkbox >(and maybe how to retrieve data... ;-) Albatross evaluates the resulting name and compares it to the value attribute (or evaluated expr/valueexpr) and adds a "checked" attribute if they're equal: >>> import albatross >>> ctx = albatross.SimpleContext('.') >>> ctx.locals.foo = 'yes' >>> ctx.locals.name = 'foo' >>> albatross.Template(ctx, '', '''''').to_html(ctx) >>> ctx.flush_content() On submission, all the inputs are merged back into ctx.locals. If the checkbox is checked, it's value will be whatever the value attribute resolves to, if not checked, it's None (from memory). So, in the above example, on submission, you would have a variable ctx.locals.foo with value 'yes' or None (I think 8-). -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From esj at harvee.org Thu Jun 26 13:26:34 2003 From: esj at harvee.org (Eric S. Johansson) Date: Wed, 25 Jun 2003 23:26:34 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: <20030626024612.A03083C426@coffee.object-craft.com.au> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> <20030626014833.230F73C426@coffee.object-craft.com.au> <3EFA59EF.2090601@harvee.org> <20030626024612.A03083C426@coffee.object-craft.com.au> Message-ID: <3EFA67EA.7040007@harvee.org> Andrew McNamara wrote: > Albatross evaluates the resulting name and compares it to the value > attribute (or evaluated expr/valueexpr) and adds a "checked" attribute > if they're equal: I was able to follow the documentation that much. ;-) > > >>> import albatross > >>> ctx = albatross.SimpleContext('.') > >>> ctx.locals.foo = 'yes' > >>> ctx.locals.name = 'foo' > >>> albatross.Template(ctx, '', '''''').to_html(ctx) > >>> ctx.flush_content() > > > On submission, all the inputs are merged back into ctx.locals. If the > checkbox is checked, it's value will be whatever the value attribute > resolves to, if not checked, it's None (from memory). > > So, in the above example, on submission, you would have a variable > ctx.locals.foo with value 'yes' or None (I think 8-). this leaves me with (yet another) question. How do you treat ctx.locals as a dictionary/array/whatever makes the easiest to programmatically create entries and search on them? I remember experimenting very early on and it didn't seem like __getattr__ and family were present. Am I just too sleep fogged? I've been playing around with locals.__dict__ to try and get a feel for what's there and at least I can see all of my spamtrap tokens but I wasn't able to access them as .local.xxx variables. for entry in context.locals.__dict__: if entry.find("token") <>-1: syslog.syslog(entry) yielded: Jun 25 23:16:42 harvee python2: token925b7d685d2747dd Jun 25 23:16:42 harvee python2: token9acb26b0dcde7145 Jun 25 23:16:42 harvee python2: token5c78e77ec4cf7748 Jun 25 23:16:42 harvee python2: tokenf2952773fad60176 Jun 25 23:16:42 harvee python2: token633a2b50bd966ad9 Jun 25 23:16:42 harvee python2: token3dc7b80d66e03957 Jun 25 23:16:42 harvee python2: tokenb7a6bc91fa70ef0e Jun 25 23:16:42 harvee python2: token6212922bbc33af37 Jun 25 23:16:42 harvee python2: token3da28ecf416b681a Jun 25 23:16:42 harvee python2: token4ca8f5cf8e5b1aee Jun 25 23:16:42 harvee python2: tokena1b2f2392f7958dd Jun 25 23:16:42 harvee python2: token18110da55c4e9755 Jun 25 23:16:42 harvee python2: token35894754db05026f Jun 25 23:16:42 harvee python2: token9b8659411055405c Jun 25 23:16:42 harvee python2: tokenaeed365de824afd6 Jun 25 23:16:42 harvee python2: token2e782e94ab7b6d0a I definitely need some sleep. I'm up early in the morning to take care of an elderly aunt in our early summer heat and go purchase her air-conditioning. ---eric From andrewm at object-craft.com.au Thu Jun 26 13:36:21 2003 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Thu, 26 Jun 2003 13:36:21 +1000 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: Message from "Eric S. Johansson" of "Wed, 25 Jun 2003 23:26:34 -0400." <3EFA67EA.7040007@harvee.org> References: <3EFA30B0.7020206@harvee.org> <20030626004643.80FFA3C426@coffee.object-craft.com.au> <3EFA4AD7.9010608@harvee.org> <20030626014833.230F73C426@coffee.object-craft.com.au> <3EFA59EF.2090601@harvee.org> <20030626024612.A03083C426@coffee.object-craft.com.au> <3EFA67EA.7040007@harvee.org> Message-ID: <20030626033621.47AAC3C426@coffee.object-craft.com.au> >this leaves me with (yet another) question. How do you treat ctx.locals >as a dictionary/array/whatever makes the easiest to programmatically >create entries and search on them? I remember experimenting very early on >and it didn't seem like __getattr__ and family were present. Am I just >too sleep fogged? > >I've been playing around with locals.__dict__ to try and get a feel for >what's there and at least I can see all of my spamtrap tokens but I wasn't >able to access them as .local.xxx variables. > > for entry in context.locals.__dict__: > if entry.find("token") <>-1: > syslog.syslog(entry) This is essentially the same thing (although it's also dumping the value of the variables): for attr, value in vars(ctx.locals).items(): if attr.beginswith('token'): syslog.syslog('%s %s' % (attr, value)) My preference would be to build a class to collect all the token attributes in one place, somewhat like the example I posted originally. There's many variations possible, of course. -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From neel at mediapulse.com Fri Jun 27 00:53:15 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 26 Jun 2003 10:53:15 -0400 Subject: [albatross-users] revisiting checkboxes.. Message-ID: Read the whole thread, and just wanted to offer up some other options; so the "I have a hammer and every problem is a nail" syndrom can be avioded =). (this is AKA "I have perl and everything can be solved with a regex"). First is, it seems you want the list of none-checked items. This seems odd; possbily consider changing the interface so that the user checks the list you are really looking for (i.e. if they check the messages to keep; have them instead check the ones to deleted?). There is the "if list not in list" python statement you can use. This uses the store the list in the session; which I also have done with large database results before without trouble (the reason there was the querey was done once and not for every page or re-sort). I would have done even larger blocks of data, but file objects cannot be pickled =) (and that's probably a good thing). And lastly, there are radio buttons, which can have the on/off and will all be sent in the request. I don't know the details of your app, so I'm not sure if the above are options or not, but just wanted to toss them out there. Mike From esj at harvee.org Fri Jun 27 02:26:10 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 26 Jun 2003 12:26:10 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: References: Message-ID: <3EFB1EA2.205@harvee.org> Michael C. Neel wrote: > First is, it seems you want the list of none-checked items. This seems > odd; possbily consider changing the interface so that the user checks > the list you are really looking for (i.e. if they check the messages to > keep; have them instead check the ones to deleted?). we went around the barn on the user interface for the spamtrap quite a few times. We've tried radio buttons, submit buttons on each line etc. but what we currently have seems to be the best minimal user interface. we start out with the following text: Instructions: Messages in the red area are strongly suspected to be spam. They have been pre-checked. Messages in the yellow area may be spam, but it's not certain. They have been left un-checked. Your job is to verify that each message is classified correctly; then press "Train" to train the anti-spam system with this new data. * If the email is spam, tick the checkbox. * If the email is not spam, clear the checkbox. * If you are not sure, check the message detail by following the subject link. * Click "Train" when all the messages on the screen are correctly marked as spam/not spam. * Repeat until all messages have been processed. To update the spamtrap display, click Refresh Display <<== link ====== then under this is the table of spamtrap items color-coded according to score as well as checked according to score. I use the checkbox state on submit to decide whether or not to pump the message into the train-as-good or train-as-bad paths in the spam discriminator. > There is the "if list not in list" python statement you can use. This > uses the store the list in the session; which I also have done with > large database results before without trouble (the reason there was the > querey was done once and not for every page or re-sort). I would have > done even larger blocks of data, but file objects cannot be pickled =) > (and that's probably a good thing). I'm currently trying the attribute method. I was fighting refactoring the code and was trying to stick with mostly the same structure of a standard CGI. Then I realized (for 10 billionth time), that if I'm encountering significant resistance solving a problem one way, I'm solving it the wrong way. So I gave in, started refactoring and it feels easier or at least cleaner than the code ahead before. It's not the best class I have ever written but it sucks less than a black hole[1]. I think storing the list and extracting information by set operations will be my method of last resort. It falls the category of brute force/bloody ignorance. > I don't know the details of your app, so I'm not sure if the above are > options or not, but just wanted to toss them out there. I appreciate the effort. I hope my explanations clarify some of the constraints I have on the implementation. Fortunately, I think the Web interface for the user configuration and the dumpster tool will be much easier. When I can show them off, I will send the list a URL. ---eric [1] yea, yea, yea, I'm an astronomy geek in addition to ham radio and computer with a taste for bad jokes. From neel at mediapulse.com Fri Jun 27 02:42:39 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Thu, 26 Jun 2003 12:42:39 -0400 Subject: [albatross-users] revisiting checkboxes.. Message-ID: If you look back at my first posts to this list; you'll see I also had a very tight interface issue that I needed help with (a set of filters, the number is unlimited and the user just keeps "add filter" or "remove filter" and each filter had a set of controld to display and remember state on because it was step 6 of 8 in a wizard). I ended up going the albatross_alias/class route and still prefer that method when it's needed. If you don't mind, do you plan on open souceing this spam tool? What are it's server reqs? Will it run on qmail? If so I'd be interested in using this when it done ;) Mike From esj at harvee.org Fri Jun 27 13:58:11 2003 From: esj at harvee.org (Eric S. Johansson) Date: Thu, 26 Jun 2003 23:58:11 -0400 Subject: [albatross-users] revisiting checkboxes.. In-Reply-To: References: Message-ID: <3EFBC0D3.8090205@harvee.org> Michael C. Neel wrote: > If you look back at my first posts to this list; you'll see I also had a > very tight interface issue that I needed help with (a set of filters, > the number is unlimited and the user just keeps "add filter" or "remove > filter" and each filter had a set of controld to display and remember > state on because it was step 6 of 8 in a wizard). I ended up going the > albatross_alias/class route and still prefer that method when it's > needed. I'll have to read up on that. One of the things that occurred to me after my last message about selling the wrong problem is that I probably need to had a new version of "list" which is "listall" which will return a list of all items in the group as well as their state. It's probably only useful for checkbox but you never know. > If you don't mind, do you plan on open souceing this spam tool? What > are it's server reqs? Will it run on qmail? If so I'd be interested in > using this when it done ;) it is open source already (camram.sourceforge.net) the current version is a few fries short of a happy meal in a few areas but the filter is fundamentally sound. What I've got on my pack is a version which uses enhancement of the python configuration variable class, a bunch of minor bug fixes. I'm working on a reimplementation of the current spamtrap user interface with extraction of a bunch of classes for reuse in the dumpster interface. Then I'll create the user configuration editing tool. camram is the first practical sender pays antispam system. I described as practical because while it does allow for sender pays e-mail, it doesn't dictate that all messages must have a stamp. There is a three filter chain between stamps, white list (who you know), and a Bayesian style discriminator. The system also includes a stamping utility designed to work with an SMTP proxy called e-mailrelay. The Bayesian discriminator is crm114 which works pretty well but is going through some fairly major changes by itself. the discriminator phase categorizes messages into good, bad, can't tell. Good is passed on to the inbox, bad and can't tell is spamtrapped. the system includes the capability of sending notices or postage to notices. I've put a great deal of effort into minimizing who gets notices. For example, only can't tell messages get notices. Additionally, if the message has indicators that it might have come from a mailing list, it won't send a message either to prevent annoying folks on a mailing list. server requirements: all needs is the ability to inject itself somewhere in the delivery process. I'm currently using procmail because it's convenient. If you want to make it work with something else all I require it is for message to be converted to python e-mail object format and I will return it in the same format. you can run the system and either global mode or individual mode. Global mode uses one set of discriminator profiles and white list for everyone on the system. individuals have their own profiles. managing the spamtrap is left up to a small number of individuals. This is typically what you would use for a corporate environment. in individual mode, everyone gets their own spamtrap, white list, discriminator profile etc. Hasn't been heavily tested because my wife doesn't want to be bothered with managing her own spamtrap. Load isn't too horrible. I have it running at one commercial client on midrange Pentium III and it's just running for them without noticeable load. Unlike Spam assassin which regularly hammered the machine and caused major headaches. the next release is waiting for: the user interface tools (no problem advertising albatross if folks want), changes to the SMTP proxy to single thread the filter/stamp generator but queue up additional requests, Java applets and CGI for the postage due notice and browser based stamp generation. would be nice to have a better authentication system than the traditional htaccess methods. needs list: help with user interface implementation (this should come as no surprise) taking over some of the work so I can concentrate on the ietf protocol proposal crypto extensions did I forget to mention the crypto extensions? In a nutshell, put your public key on every single message outbound. Once you've exchanged stamped messages with someone, you can "trust their key" a little bit. Then you can sign and encrypt messages between yourselves automatically with no passphrases. Yes, it has some weaknesses like MITM but on the other hand, it's an order of magnitude more secure than postcard mail today and far far easier to use than pgp. I tend to get a bit passionate about this project and ramble on especially if I've been up too late like I have been again. ---eric From djc at object-craft.com.au Sun Jun 29 14:29:00 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 14:29:00 +1000 Subject: [albatross-users] Documentation bug In-Reply-To: References: Message-ID: >>>>> "Dave" == Dave Cole writes: Dave> The problem was caused by a "bug" in the latex2html extensions Dave> in the Python Doc directory. I reported this some time ago - it Dave> looks like it has been fixed in 2.3. Dave> I will rebuild all of the documentation with Python 2.3 and Dave> reinstall. Still having funny problems with PNG image Dave> generation on this machine... I gave up trying to work out why the image generation is working at home but not at work. It is something to do with pstoimg from the latex2html package but I can't figure it out. At work I get zero length images... - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 29 14:36:39 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 14:36:39 +1000 Subject: [albatross-users] Documentation bug In-Reply-To: References: Message-ID: >>>>> "Dave" == Dave Cole writes: Dave> I gave up trying to work out why the image generation is working Dave> at home but not at work. It is something to do with pstoimg Dave> from the latex2html package but I can't figure it out. At work Dave> I get zero length images... Ooops - I forgot to mention that I have placed the 2.3 formatted HTML up on the website http://www.object-craft.com.au/projects/albatross/albatross/ Still more work to go before I am happy with the templates reference. I want to have a crack at the suggestion from Michael C. Neel: > Looks like I missed this post too, but this looks really great. > The one part I would add is an example of each tag on the form > side being parsed on submission, i.e. showing how to get at > the data from a etc. > # page module code, inside page_process(), saves the uploaded file > if ctx.req_equals("resume") and len(ctx.locals.resume.value): > filename = "/home/uploads/resumes/new_file.txt" > file = open(filename, 'wb') > file.writelines(ctx.locals.image.value) > file.close() I should also go back through the list looking for more comments on the new documentation. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 29 15:49:13 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 15:49:13 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <9948525.1056116333@SHEILA-LAPTOP> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> The documentation did not make clear to me that, by using the Sheila> al-for tag, that albatross was creating a ListIterator type Sheila> that had these methods which I could use. [snip] Sheila> I would suggest adding some language to the docs which states Sheila> that, by using the al-for tag, that albatross instantiates a Sheila> ListIterator object, as defined by the class definition in the Sheila> tags.py file, and that the ListIterator object will have the Sheila> following methods available to it ...blah blah... In response to this and the concerns from Matt Goodall I have added some more content to the start of the reference. Can you please look at the following and tell me if it helps? http://www.object-craft.com.au/projects/albatross/albatross/tag-for.html - Dave -- http://www.object-craft.com.au From sheila at thinkspot.net Sun Jun 29 16:30:04 2003 From: sheila at thinkspot.net (Sheila King) Date: Sat, 28 Jun 2003 23:30:04 -0700 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> Message-ID: <981458372.1056843004@goddess> --On Sunday, June 29, 2003 3:49 PM +1000 Dave Cole wrote: >>>>>> "Sheila" == Sheila King writes: > > Sheila> The documentation did not make clear to me that, by using the > Sheila> al-for tag, that albatross was creating a ListIterator type > Sheila> that had these methods which I could use. > > [snip] > > Sheila> I would suggest adding some language to the docs which states > Sheila> that, by using the al-for tag, that albatross instantiates a > Sheila> ListIterator object, as defined by the class definition in the > Sheila> tags.py file, and that the ListIterator object will have the > Sheila> following methods available to it ...blah blah... > > In response to this and the concerns from Matt Goodall I have added > some more content to the start of the reference. Can you > please look at the following and tell me if it helps? > > > http://www.object-craft.com.au/projects/albatross/albatross/tag-for.html > > - Dave > Dave, I think this is much clearer now. This makes all the difference in the world, IMHO: The tag uses an instance of the ListIterator (5.3.7.8) identified in the local namespace by the iter (5.3.7.5) attribute to iterate over the sequence defined by the expression in the expr (5.3.7.3) attribute. Having that practically at the beginning, especially with references to the rest of the documentation, makes it much clearer what exactly is going on. Thanks for listening, -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org From djc at object-craft.com.au Sun Jun 29 18:42:26 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 18:42:26 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <981458372.1056843004@goddess> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> Message-ID: >>>>> "Sheila" == Sheila King writes: Sheila> Dave, I think this is much clearer now. This makes all the Sheila> difference in the world, IMHO: Sheila> The tag uses an instance of the ListIterator (5.3.7.8) Sheila> identified in the local namespace by the iter (5.3.7.5) Sheila> attribute to iterate over the sequence defined by the Sheila> expression in the expr (5.3.7.3) attribute. Sheila> Having that practically at the beginning, especially with Sheila> references to the rest of the documentation, makes it much Sheila> clearer what exactly is going on. Sheila> Thanks for listening, No problem. Thanks for raising your concerns. We are all too close to the software to see these sorts of gaps in the documentation. I have been trying to make the documentation better - a slow and difficult job. - Dave -- http://www.object-craft.com.au From matt at pollenation.net Sun Jun 29 19:12:37 2003 From: matt at pollenation.net (Matt Goodall) Date: 29 Jun 2003 10:12:37 +0100 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <981458372.1056843004@goddess> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> Message-ID: <1056877957.5434.265.camel@localhost> On Sun, 2003-06-29 at 07:30, Sheila King wrote: > Dave, I think this is much clearer now. This makes all the difference in > the world, IMHO: I agree, this is *really* clear now. Thanks Dave. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt at pollenation.net From djc at object-craft.com.au Sun Jun 29 19:38:46 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 19:38:46 +1000 Subject: [albatross-users] New tag reference In-Reply-To: References: Message-ID: > > Looks like I missed this post too, but this looks really > > great. The one part I would add is an example of each tag on > > the form side being parsed on submission, i.e. showing how > > to get at the data from a etc. > > What you have is: > > >>> import albatross > >>> class Ctx(albatross.SimpleContext): > ... def input_add(self, *args): > ... print args > ... > >>> ctx = Ctx('.') > >>> albatross.Template(ctx, '', ''' > ... > ... ''').to_html(ctx) > ('file', 'resume', None, 0) > >>> ctx.flush_content() > > > What I'd like to see added after that is: > > # page module code, inside page_process(), saves the uploaded file > if ctx.req_equals("resume") and len(ctx.locals.resume.value): > filename = "/home/uploads/resumes/new_file.txt" > file = open(filename, 'wb') > file.writelines(ctx.locals.image.value) > file.close() > > Actually, it should be alittle more than that, showing getting the > filename as it was on the client's system - but this is off the top of > my head and I don't remember where that's stored atm (hence the need for > the reference =) Can you please check the following and tell me if it addresses the problem you raised? http://www.object-craft.com.au/projects/albatross/albatross/tag-input-generic.html http://www.object-craft.com.au/projects/albatross/albatross/tag-input-image.html http://www.object-craft.com.au/projects/albatross/albatross/tag-input-file.html - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 29 19:42:54 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 19:42:54 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <1056877957.5434.265.camel@localhost> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Sun, 2003-06-29 at 07:30, Sheila King wrote: >> Dave, I think this is much clearer now. This makes all the >> difference in the world, IMHO: Matt> I agree, this is *really* clear now. I am at the end of the largest outstanding documentation task - the tag reference. Now would be a good time to hit me with issues before I launch into another task. I still need to check the mixin reference and prepackaged application and execution context. - Dave -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 29 20:34:51 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 20:34:51 +1000 Subject: [albatross-users] Renaming application and execution context classes Message-ID: A long time ago Cameron Blackwood posted to this list complaining (quite rightly) that the application and execution context classes were badly named. He made some suggestions here. http://www.object-craft.com.au/pipermail/albatross-users/2002-November/000166.html I agree that the current class names could be improved but I cannot seem to come up with anything really good. Below is a table of the current packaged classes and a new name suggestion. If we do perform a rename the existing names will remain as aliases to the renamed classes. Can anyone think of a better naming scheme? What are peoples' feelings about a rename? - Dave Current Class New Class =============================== ========================= SimpleContext TemplateCtx AppContext SimpleAppContext ClientSessCtx SessionAppContext ServerSessCtx SessionFileAppContext FileSessCtx Application SimpleApp ClientSessPageObjApp SimpleSessionApp ServerSessPageObjApp SimpleSessionFileApp FileSessPageObjApp ModularApp ClientSessPageModApp ModularSessionApp ServerSessPageModApp ModularSessionFileApp FileSessPageModApp RandomModularApp ClientSessByURLPageModApp RandomModularSessionApp ServerSessByURLPageModApp RandomModularSessionFileApp FileSessByURLPageModApp -- http://www.object-craft.com.au From djc at object-craft.com.au Sun Jun 29 21:02:17 2003 From: djc at object-craft.com.au (Dave Cole) Date: 29 Jun 2003 21:02:17 +1000 Subject: [albatross-users] Standalone HTTP Albatross server In-Reply-To: <1056331020.29342.79.camel@localhost> References: <1056331020.29342.79.camel@localhost> Message-ID: > Attached is the first cut at a simple, standalone HTTP server script > for Albatross apps. It's been written for 1.10pre1 although there > seems to be a bug in that version which stops it actually > working. See my post of 19 Jun 2003 for more on the bug and a > possible solution. I finally got enough things out of the way to have a bit of a play with this stuff. > The script is working ok for me but it has only had minimal testing > and has some known limitations: > > * No file upload support. I will try to sort that out soon. That would be cool but not essential. > * It uses the standard BaseHTTPServer module so it's not much more > that a toy. It's ok for local development and as a very low use > server i.e. for single user, web-based apps. That is not big deal. Greg (one of the programmers here) used Albatross in an embedded control system. This code would have been very useful in further reducing the memory footprint. > I'm posting this now in the hope that it is useful in its current > form (i.e. without file upload) and maybe to get some feedback. I did the simplest thing I could think of and copied some of the sample code from the manual to test this: I saved your code as httpd.py It works like a bought one. Extremely cool. Andrew, do you think we should put this into Albatross now? - Dave - - cheeky.py - - - - - - - - - - - - - - - - - - - - - - - - - - - - from albatross import SimpleApp import httpd class Form: def page_enter(self, ctx): ctx.locals.text = ctx.locals.singleton = ctx.locals.group = \ ctx.locals.radio = ctx.locals.select = None ctx.locals.num = 0 ctx.add_session_vars('num') def page_display(self, ctx): ctx.locals.num += 1 ctx.run_template('form.html') app = SimpleApp(base_url = 'cheeky.py', template_path = '.', start_page = 'form', secret = '-=-secret-=-') app.register_page('form', Form()) server = httpd.HTTPServer(app, 8080) server.serve_forever() - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - form.html (from albatross documentation) - - - - - - - - - - - - - Display Form Input Input some values to the following form and press the submit button. Text field:
Singleton checkbox:
Checkbox group:
Radio buttons:
Option menu: option1 option2 option3
number of requests:
text:
singleton:
group:
radio:
select:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- http://www.object-craft.com.au From matt at pollenation.net Sun Jun 29 23:52:38 2003 From: matt at pollenation.net (Matt Goodall) Date: 29 Jun 2003 14:52:38 +0100 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> Message-ID: <1056894758.5434.271.camel@localhost> On Sun, 2003-06-29 at 10:42, Dave Cole wrote: > I am at the end of the largest outstanding documentation task - the > tag reference. Now would be a good time to hit me with issues before > I launch into another task. Is that a hint? ;-) -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt at pollenation.net From matt at pollenation.net Mon Jun 30 00:23:24 2003 From: matt at pollenation.net (Matt Goodall) Date: 29 Jun 2003 15:23:24 +0100 Subject: [albatross-users] Standalone HTTP Albatross server In-Reply-To: References: <1056331020.29342.79.camel@localhost> Message-ID: <1056896603.30505.303.camel@localhost> Great stuff, I'm glad it worked for you too. However, are you sure it's working when the 'list' attribute is set? I'm quite surprised since the Request class does: def field_value(self, name): return self._fields[name][0] ~~~~~ I don't actually know how the list stuff works though, perhaps the above does not matter? I'll try to test 'list' explicitly and see what happens. I'm fairly sure that I will need file upload support so it should get fixed. The main issue is finding time to find out how to do it - the cgi module is not the easiest module in Python's stdlib. I will look at how the other Request adapters work for guidance. Do you have any issues with how it is implemented? Are there better ways of doing this stuff that I don't know about? Cheers, Matt On Sun, 2003-06-29 at 12:02, Dave Cole wrote: > > Attached is the first cut at a simple, standalone HTTP server script > > for Albatross apps. It's been written for 1.10pre1 although there > > seems to be a bug in that version which stops it actually > > working. See my post of 19 Jun 2003 for more on the bug and a > > possible solution. > > I finally got enough things out of the way to have a bit of a play > with this stuff. > > > The script is working ok for me but it has only had minimal testing > > and has some known limitations: > > > > * No file upload support. I will try to sort that out soon. > > That would be cool but not essential. > > > * It uses the standard BaseHTTPServer module so it's not much more > > that a toy. It's ok for local development and as a very low use > > server i.e. for single user, web-based apps. > > That is not big deal. Greg (one of the programmers here) used > Albatross in an embedded control system. This code would have been > very useful in further reducing the memory footprint. > > > I'm posting this now in the hope that it is useful in its current > > form (i.e. without file upload) and maybe to get some feedback. > > I did the simplest thing I could think of and copied some of the > sample code from the manual to test this: > > I saved your code as httpd.py > > It works like a bought one. Extremely cool. > > Andrew, do you think we should put this into Albatross now? > > - Dave > > - - cheeky.py - - - - - - - - - - - - - - - - - - - - - - - - - - - - > from albatross import SimpleApp > import httpd > > class Form: > def page_enter(self, ctx): > ctx.locals.text = ctx.locals.singleton = ctx.locals.group = \ > ctx.locals.radio = ctx.locals.select = None > ctx.locals.num = 0 > ctx.add_session_vars('num') > > def page_display(self, ctx): > ctx.locals.num += 1 > ctx.run_template('form.html') > > app = SimpleApp(base_url = 'cheeky.py', > template_path = '.', > start_page = 'form', > secret = '-=-secret-=-') > app.register_page('form', Form()) > > server = httpd.HTTPServer(app, 8080) > server.serve_forever() > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > > - - form.html (from albatross documentation) - - - - - - - - - - - - - > > > Display Form Input > > > Input some values to the following form and press the submit button. > > Text field:
> Singleton checkbox:
> Checkbox group: > >
> Radio buttons: > >
> Option menu: > > option1 > option2 > option3 > > >
> number of requests:
> text:
> singleton:
> group:
> radio:
> select:
> > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt at pollenation.net From djc at object-craft.com.au Mon Jun 30 08:03:38 2003 From: djc at object-craft.com.au (Dave Cole) Date: 30 Jun 2003 08:03:38 +1000 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: <1056894758.5434.271.camel@localhost> References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> <1056894758.5434.271.camel@localhost> Message-ID: >>>>> "Matt" == Matt Goodall writes: Matt> On Sun, 2003-06-29 at 10:42, Dave Cole wrote: >> I am at the end of the largest outstanding documentation task - the >> tag reference. Now would be a good time to hit me with issues >> before I launch into another task. Matt> Is that a hint? ;-) Maybe... - Dave -- http://www.object-craft.com.au From neel at mediapulse.com Mon Jun 30 09:04:24 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Sun, 29 Jun 2003 19:04:24 -0400 Subject: [albatross-users] New tag reference Message-ID: Dave, You're all over the docs this week =) Yes, this looks really awesome and helps show the "full circle" of a form. Since using albatross I now know the request objects are from the cgi FieldStorage class, or at least act like they are; but when I started out I'd never programmed with the cgi module (nor do I intend to, lol) so I was a bit lost. Those that have used the cgi module probably don't need this, but those of us that didn't will find this vey helpful. At some point you might consider documenting these objects completely (read: cut-n-paste from the cgi.Fieldstorage docs) just to have it all in one place; but this isn't all that important. Mike > -----Original Message----- > From: Dave Cole [mailto:djc at object-craft.com.au] > Sent: Sunday, June 29, 2003 5:39 AM > To: Michael C. Neel > Cc: albatross-users at object-craft.com.au > Subject: Re: [albatross-users] New tag reference > > > > > > Looks like I missed this post too, but this looks really > > > great. The one part I would add is an example > of each tag on > > > the form side being parsed on submission, i.e. > showing how > > > to get at the data from a etc. > > > > What you have is: > > > > >>> import albatross > > >>> class Ctx(albatross.SimpleContext): > > ... def input_add(self, *args): > > ... print args > > ... > > >>> ctx = Ctx('.') > > >>> albatross.Template(ctx, '', ''' > > ... > > ... ''').to_html(ctx) > > ('file', 'resume', None, 0) > > >>> ctx.flush_content() > > > > > > What I'd like to see added after that is: > > > > # page module code, inside page_process(), saves the > uploaded file > > if ctx.req_equals("resume") and len(ctx.locals.resume.value): > > filename = "/home/uploads/resumes/new_file.txt" > > file = open(filename, 'wb') > > file.writelines(ctx.locals.image.value) > > file.close() > > > > Actually, it should be alittle more than that, showing > getting the > > filename as it was on the client's system - but this > is off the top of > > my head and I don't remember where that's stored atm > (hence the need for > > the reference =) > > Can you please check the following and tell me if it > addresses the > problem you raised? > http://www.object-craft.com.au/projects/albatross/albatross/tag-input-ge neric.html http://www.object-craft.com.au/projects/albatross/albatross/tag-input-im age.html http://www.object-craft.com.au/projects/albatross/albatross/tag-input-fi le.html - Dave -- http://www.object-craft.com.au From neel at mediapulse.com Mon Jun 30 09:11:38 2003 From: neel at mediapulse.com (Michael C. Neel) Date: Sun, 29 Jun 2003 19:11:38 -0400 Subject: [albatross-users] Installing multiple copies of Albatross Message-ID: All, I'm trying to figure out how to install several versions of albatross on the same system. I have quite a few sites running on albatross, so I don't want a massive task to upgrade with each new version, esp if there is a rename of classes soon. I tried to place albatross into my modules directoy (I use mod_python) but no matter what I tried I couldn't get the local version of Albatross to be used over the /usr/lib one. I could rename albatross to albatross110pre, but that looks like a lot of code to touch in the module to stop the albatross imports from getting the wrong version. I think I'm missing something simple here, because no one else has mentioned this, so any tips would be helpful. Thanks, Mike From matt at pollenation.net Mon Jun 30 09:34:57 2003 From: matt at pollenation.net (Matt Goodall) Date: 30 Jun 2003 00:34:57 +0100 Subject: [albatross-users] al-for and Template frustration and confusion In-Reply-To: References: <49126450.1056069096@SHEILA-LAPTOP> <20030620075929.E5F743C332@coffee.object-craft.com.au> <9948525.1056116333@SHEILA-LAPTOP> <981458372.1056843004@goddess> <1056877957.5434.265.camel@localhost> Message-ID: <1056929696.5434.427.camel@localhost> On Sun, 2003-06-29 at 10:42, Dave Cole wrote: > I am at the end of the largest outstanding documentation task - the > tag reference. Now would be a good time to hit me with issues before > I launch into another task. The new tag reference looks really good. For me, there's enough detail in there without it getting too verbose and, as I have previously mentioned, I particularly like the way each attribute has its own section. Since I couldn't see much to comment on in the tag ref I started reading from the beginning instead. Here's some comments up to the end of section 3 (which I realise I have never read properly before!) ... Introduction ~~~~~~~~~~~~ I think the following are either missing or not specifically listed: - simple and flexible to use (as opposed to the framework itself) - lightweight enough for cgi - controller to route a request to the correct handler - custom tags (jsp-like but simple to use) - form population and parsing Front Matter ~~~~~~~~~~~~ Add a "See Also" link to www.fastcgi.com and maybe python.org 3.5.3 Multiple Argument Macros ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This could probably do with a small example anyway. -- Matt Goodall, Pollenation Internet Ltd w: http://www.pollenation.net e: matt at pollenation.net From korg at darkqueen.org Mon Jun 30 17:02:31 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 30 Jun 2003 17:02:31 +1000 Subject: [albatross-users] Re: Renaming application and execution context classes In-Reply-To: Your message of "29 Jun 2003 20:34:51 +1000." Message-ID: <200306300702.h5U72V004789@firewall.darkqueen.org> Dave Cole writes In message : | A long time ago Cameron Blackwood posted to this list complaining | (quite rightly) that the application and execution context classes | were badly named. He made some suggestions here. Im still on the list ;) Im just quiet because I havnt had much albatross hacking time :). | | I agree that the current class names could be improved but I cannot | seem to come up with anything really good. Below is a table of the | current packaged classes and a new name suggestion. Yeah, its hard. :-/ | | Can anyone think of a better naming scheme? | | What are peoples' feelings about a rename? I (obviously) think it is a great idea :) | | - Dave | | Current Class New Class | =============================== ========================= | SimpleContext TemplateCtx | AppContext | | SimpleAppContext ClientSessCtx | SessionAppContext ServerSessCtx | SessionFileAppContext FileSessCtx I like these :) Very obvious and clear | | Application | | SimpleApp ClientSessPageObjApp | SimpleSessionApp ServerSessPageObjApp | SimpleSessionFileApp FileSessPageObjApp | | ModularApp ClientSessPageModApp | ModularSessionApp ServerSessPageModApp | ModularSessionFileApp FileSessPageModApp I still find these a little confusing, (but then I never did use the Modular versions at all :-). So if youre looking for suggestions, then: ClassApp <-- I guess simple is ok, but you need to use classes so isnt that a little clearer? | | RandomModularApp ClientSessByURLPageModApp | RandomModularSessionApp ServerSessByURLPageModApp | RandomModularSessionFileApp FileSessByURLPageModApp I really havnt looked too far under the hood for Albatross, so this is probably a dumb question... but.. Should the app really care how the context is stored?? Isnt that the context's job? I guess it's because the App needs to know where/how to load the context (or what type of context to load). But wouldnt you be better to make the programmer hard code enough information into the code so that the context type can be created and then you would have 3 app classes rather than 9. Yeah, I guess Im still not clear on why the App needs to care how the session is stored. Oh and I still think that accepting, but ignoring, any Albatross_Application.__init__ arguments from other session/context storage types to allow you to switch between App methods is a good idea ;) Oh and Im working on using albatross as a UI for some graphics work that Im doing. It uses ismap images to move the view around etc and albatross makes it nice and easy. This post has made me look through the albatross documentation again and I have a couple of comments on that: 1) I cant find (easily) a section that lists exactly what is called with any request http://www.object-craft.com.au/projects/albatross/albatross/fig-presimpexec.html seems to come close. But it says: "It is instructive to look at the exact code from Albatross that implements the processing sequence." but then it doesnt mention page_process, page_display functions the example at the end of the page use. 2) Some more description on what a SessionAppContext/ServerSessCtx is might also be cool. Eg, for my graphics viewer, i have to load the world state in each cgi request, does the server save me from doing this? (Im just going to go and code up an example to answer this myself, but it does seem a little ugly to have to do that to work out how it works :) cheers, cam PS: Dont take comments in this post as -ive, I think albatross totally _ROCKS_!! -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- One thought driven home is better than three left on base. From korg at darkqueen.org Mon Jun 30 17:17:54 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 30 Jun 2003 17:17:54 +1000 Subject: [albatross-users] Re: Renaming application and execution context classes In-Reply-To: Your message of "Mon, 30 Jun 2003 17:02:31 +1000." Message-ID: <200306300717.h5U7Hs105061@firewall.darkqueen.org> "Cameron Blackwood" writes: | | But wouldnt you be better to make the programmer hard code enough | information into the code so that the context type can be created and then | you would have 3 app classes rather than 9. | [....] | | This post has made me look through the albatross documentation again | and I have a couple of comments on that: | http://www.object-craft.com.au/projects/albatross/albatross/app-popview3.html "Adding Server-Side Session Support to Popview" "The new application prologue looks like this: #!/usr/bin/python from albatross import SimpleSessionApp, SessionAppContext " and then: " def create_context(self): return AppContext(self)" but that should be: " def create_context(self): return SessionAppContext(self)" cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Where it is a duty to worship the sun it is pretty sure to be a crime to examine the laws of heat. -- Christopher Morley From korg at darkqueen.org Mon Jun 30 17:21:57 2003 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 30 Jun 2003 17:21:57 +1000 Subject: [albatross-users] Re: Renaming application and execution context classes In-Reply-To: Your message of "Mon, 30 Jun 2003 17:02:31 +1000." Message-ID: <200306300721.h5U7Lv605110@firewall.darkqueen.org> "Cameron Blackwood" writes: | This post has made me look through the albatross documentation again | and I have a couple of comments on that: | http://www.object-craft.com.au/projects/albatross/albatross/app-proto-new.html looks kinda weird: ?

?

  ? "new " appid " " age CRLF
  ? 
  ? 
? ?

? Successful response will be a line of the form: ? ?

?

  ? "OK " sesid CRLF
  ? 
? I assume the "'s are ment to be more clear? cheers, cam -- / `Rev Dr' cam at darkqueen.org Roleplaying, virtual goth \ < http://darkqueen.org Poly, *nix, Python, C/C++, genetics, ATM > \ [+61 3] 9809 1523[h] skeptic, Evil GM(tm). Sysadmin for hire / ---------- Random Quote ---------- Just remember, wherever you go, there you are. -- Buckaroo Bonzai From esj at harvee.org Mon Jun 30 21:36:56 2003 From: esj at harvee.org (Eric S. Johansson) Date: Mon, 30 Jun 2003 07:36:56 -0400 Subject: [albatross-users] Renaming application and execution context classes In-Reply-To: References: Message-ID: <3F0020D8.4020706@harvee.org> Dave Cole wrote: > A long time ago Cameron Blackwood posted to this list complaining > (quite rightly) that the application and execution context classes > were badly named. He made some suggestions here. > > http://www.object-craft.com.au/pipermail/albatross-users/2002-November/000166.html > > I agree that the current class names could be improved but I cannot > seem to come up with anything really good. Below is a table of the > current packaged classes and a new name suggestion. > > If we do perform a rename the existing names will remain as aliases to > the renamed classes. > > Can anyone think of a better naming scheme? > > What are peoples' feelings about a rename? given that I'm just started to get my mind around the albatross way, I'm not sure I'm the best person to listen to but here is my two cents worth. Change should improve the ability for the newbie to comprehend and the expert to reference/identify. It strikes me that the proposed class namings do neither. To me, simple context is far more descriptive of what the class does than template context. This is more apparent when you contrast simple application versus client session page object application. On a personal note, I find StudleyCaps quite disturbing. In 1994 after being a programmer for 18 years, my hands gave out on me and I am now mostly dependent on speech recognition for most computer operations. it's mostly noticeable when I don't pay full attention to this recognition errors and don't fix the wrong or missing words. Names such as TemplateCtx need to be spelled out as cap template no space cap letter charlie tango x-ray every time it is used. names like cap client no space cap letters Sierra echo Sierra Sierra no space cap page letter cap Oscar bravo Juliet no space alpha papa papa leave me feeling somewhat despondent. If I add words like the below to my vocabulary, it degrades my overall recognition for ordinary English. I'm currently working on a technique to partition the naming problem so I can improve recognition but dynamically add coding names but it's slow going. Eventually, I'll need to figure out how to make Emacs gave me feedback on what class/method is currently active so I can construct the right vocabulary for names but that's a different conversation. again, this is a long-winded way of saying that ordinary_words separated_by_the_underscore_character is preferable to me and that I subscribe to the school of using active words when naming classes and methods. For example: SimpleContext maybe would be better described as: create_simple_albatross_environment because that is what it does. It creates an environment in which you can define variable elements which fill in variables in a template, retrieve field values from a template, etc. It doesn't create a template (that's defined in the load_template method). it is arguable whether or not what it returns can be considered a context or an object. In either case, it creates something not is something as for the other names, personally, I find names like ClientSessPageModApp and FileSessByURLPageModApp more obscuring than illuminating. ---eric