From andrewm at object-craft.com.au Tue Aug 16 17:20:51 2005 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Tue, 16 Aug 2005 17:20:51 +1000 Subject: [albatross-users] Albatross 1.32 released Message-ID: <20050816072051.4899F6F4064@longblack.object-craft.com.au> OVERVIEW Albatross is a small toolkit for developing highly stateful web applications. The toolkit has been designed to take a lot of the pain out of constructing intranet applications although you can also use Albatross for deploying publicly accessed web applications. In slightly more than 4500 lines of Python (according to pycount) you get the following: * An extensible HTML templating system similar to DTML including tags for: - Conditional processing. - Macro definition and expansion. - Sequence iteration and pagination. - Tree browsing. - Lookup tables to translate Python values to arbitrary template text. * Application classes which offer the following features: - Optional server side or browser side sessions. - The ability to place Python code for each page in a dynamically loaded module, or to place all page processing code in a single mainline. * The ability to deploy applications as CGI, FastCGI, mod_python or a pure python HTTP server by changing less than 10 lines of code. The toolkit application functionality is defined by a collection of fine grained mixin classes. Nine different application types and six different execution contexts are prepackaged, you are able to define your own drop in replacements for any of the mixins to alter any aspect of the toolkit semantics. Application deployment is controlled by your choice of either cgi, FastCGI, mod_python, or BaseHTTPServer Request class. It should be possible to develop a Request class for Medusa or Twisted to allow applications to be deployed on those platforms with minimal changes. Albatross comes with over 170 pages of documentation. HTML, PDF and PostScript formatted documentation is available from the toolkit homepage. The toolkit homepage: http://www.object-craft.com.au/projects/albatross/ The Albatross mailing list subscription and archives: http://object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users BUGFIXES SINCE 1.30: * To obtain a reference to the current frame, _caller_globals was raising and catching an exception, then extracting the tb_frame member of sys.exc_traceback. sys.exc_traceback was deprecated in python 1.5 as it is not thread-safe. It now appears to be unreliable in 2.4, so _caller_globals has been changed to use sys._getframe(). * If ctx.set_page() was called from within the start page, then the wrong page methods (page_enter, page_display, etc) would be called (those of the initial page, rather than the page requested via set_page). * Fixes to handling of missing RandomPage page modules. From sheila at thinkspot.net Wed Aug 17 15:47:13 2005 From: sheila at thinkspot.net (Sheila King) Date: Tue, 16 Aug 2005 22:47:13 -0700 Subject: [albatross-users] Problem with ctx.get_value Message-ID: <6277396C102E01BD52C499B2@[192.168.1.102]> I am flabbergasted, and cannot figure out what may be causing this problem. Basically, I have a form that prompts the user for (among other form fields) a four-digit year. I do usual form validation type stuff to ensure that it is in fact a four digit year that has been entered, and not something else. Usually the whole thing works just fine, handles invalid data fine, and handles good data fine as well. There is one exception. If someone enters a non-zero integer value with leading zeros, the page throws an exception. This occurs in albatross 1.20, 1.30 and 1.32 Here is a sample traceback: Traceback (most recent call last): File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 282, in run self.process_request(ctx) File "mgr.py", line 95, in process_request return PageModuleMixin.process_request(self, ctx) File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 462, in process_request func(ctx) File "./pages/setquestion.py", line 158, in page_process qaForms.checkform(ctx, formfields) File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 511, in checkform striptrailingspaces(ctx, formfields) File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 113, in striptrailingspaces fieldvalue = ctx.get_value(formfield) File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 452, in get_value return self._get_value(name) File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 440, in _get_value return eval(name, {}, self.locals.__dict__) File "", line 1 0238 ^ SyntaxError: invalid token The error occurs in the albatross _get_value function, on this line of code: return eval(name, {}, self.locals.__dict__) I thought I would create a simple, proof-of-concept example of this problem (figuring the problem was clearly with albatross???), however, when I made a barebones sample form with only the year field and a submit button, calling get_value on this field did not produce the same error. It did not produce any error at all. I'm kind of puzzled on this one. I have looked over and over my code that leads up to these statements, and there is nothing I can see that would cause any kind of issue like this. Thoughts? Ideas? Tell me to go back and look at it again? Dunno. -- Sheila King sheila at thinkspot.net http://www.thinkspot.net/sheila/ From andrewm at object-craft.com.au Wed Aug 17 16:24:53 2005 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 17 Aug 2005 16:24:53 +1000 Subject: [albatross-users] Problem with ctx.get_value In-Reply-To: <6277396C102E01BD52C499B2@[192.168.1.102]> References: <6277396C102E01BD52C499B2@[192.168.1.102]> Message-ID: <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> >If someone enters a non-zero integer value with leading zeros, the page >throws an exception. This occurs in albatross 1.20, 1.30 and 1.32 I think things have gone wrong by line 113 of qaForms.py. What does the "formfield" variable contain immediately prior to the exception? >Here is a sample traceback: > >Traceback (most recent call last): > File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 282, in run > self.process_request(ctx) > File "mgr.py", line 95, in process_request > return PageModuleMixin.process_request(self, ctx) > File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 462, in process_request > func(ctx) > File "./pages/setquestion.py", line 158, in page_process > qaForms.checkform(ctx, formfields) > File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 511, in checkform > striptrailingspaces(ctx, formfields) > File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 113, in striptrailingspaces > fieldvalue = ctx.get_value(formfield) > File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 452, in get_value > return self._get_value(name) > File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 440, in _get_value > return eval(name, {}, self.locals.__dict__) > File "", line 1 > 0238 > ^ >SyntaxError: invalid token -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From sheila at thinkspot.net Wed Aug 17 17:50:41 2005 From: sheila at thinkspot.net (Sheila King) Date: Wed, 17 Aug 2005 00:50:41 -0700 Subject: [albatross-users] Problem with ctx.get_value In-Reply-To: <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> References: <6277396C102E01BD52C499B2@[192.168.1.102]> <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> Message-ID: Maybe this is a bug in Python 2.4.1. While trying to think of a way to figure out the value of the formfield, without calling the ctx.get_value function, I tried this in the interactive shell: iMac:~ sheilaking$ python2.4 Python 2.4.1 (#2, Mar 31 2005, 00:05:10) [GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin OK, I was pretty sure it was just a string of the digits 0238, but I changed line 113 in qaForms to the following: if formfield == 'year': debug("ctx.locals.year=`%s`" % repr(ctx.locals.year)) fieldvalue = ctx.get_value(formfield) *note: debug is a function that simply writes out debugging statements to a text file for me. Here is the output of the debug statement above: *** Wed Aug 17 03:45:13 2005 ctx.locals.year=`'0238'` So, it looks to me like it is simply a string of four digits, namely, 0238 and when I call ctx.get_value on the formfield "year", I get an exception. I'm still scratching my head over this. I tried this with Python2.2 also, and still get the same error. -- Sheila King sheila at thinkspot.net http://www.thinkspot.net/sheila/ --On Wednesday, August 17, 2005 4:24 PM +1000 Andrew McNamara wrote: >> If someone enters a non-zero integer value with leading zeros, the page >> throws an exception. This occurs in albatross 1.20, 1.30 and 1.32 > > I think things have gone wrong by line 113 of qaForms.py. What does the > "formfield" variable contain immediately prior to the exception? > >> Here is a sample traceback: >> >> Traceback (most recent call last): >> File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 282, in run >> self.process_request(ctx) >> File "mgr.py", line 95, in process_request >> return PageModuleMixin.process_request(self, ctx) >> File "/big/dom/xquestadmin/cgi-dev/albatross/app.py", line 462, in >> process_request func(ctx) >> File "./pages/setquestion.py", line 158, in page_process >> qaForms.checkform(ctx, formfields) >> File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 511, in checkform >> striptrailingspaces(ctx, formfields) >> File "/big/dom/xquestadmin/cgi-dev/qaForms.py", line 113, in >> striptrailingspaces fieldvalue = ctx.get_value(formfield) >> File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 452, in >> get_value return self._get_value(name) >> File "/big/dom/xquestadmin/cgi-dev/albatross/context.py", line 440, in >> _get_value return eval(name, {}, self.locals.__dict__) >> File "", line 1 >> 0238 >> ^ >> SyntaxError: invalid token > -- > Andrew McNamara, Senior Developer, Object Craft > http://www.object-craft.com.au/ > From sheila at thinkspot.net Wed Aug 17 17:52:40 2005 From: sheila at thinkspot.net (Sheila King) Date: Wed, 17 Aug 2005 00:52:40 -0700 Subject: [albatross-users] Problem with ctx.get_value In-Reply-To: References: <6277396C102E01BD52C499B2@[192.168.1.102]> <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> Message-ID: --On Wednesday, August 17, 2005 12:50 AM -0700 Sheila King wrote: > Maybe this is a bug in Python 2.4.1. Scratch that. I do NOT mean it is a bug in Python 2.4.1. I started to write one version of a response, and then went back and rewrote. Guess I missed taking that line out. Oops. -- Sheila King sheila at thinkspot.net http://www.thinkspot.net/sheila/ From andrewm at object-craft.com.au Wed Aug 17 18:07:46 2005 From: andrewm at object-craft.com.au (Andrew McNamara) Date: Wed, 17 Aug 2005 18:07:46 +1000 Subject: [albatross-users] Problem with ctx.get_value In-Reply-To: References: <6277396C102E01BD52C499B2@[192.168.1.102]> <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> Message-ID: <20050817080746.5EE2D6F4262@longblack.object-craft.com.au> >While trying to think of a way to figure out the value of the formfield, >without calling the ctx.get_value function, I tried this in the interactive >shell: > >iMac:~ sheilaking$ python2.4 >Python 2.4.1 (#2, Mar 31 2005, 00:05:10) >[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin >OK, I was pretty sure it was just a string of the digits 0238, but I >changed line 113 in qaForms to the following: > >if formfield == 'year': > debug("ctx.locals.year=`%s`" % repr(ctx.locals.year)) >fieldvalue = ctx.get_value(formfield) > >*note: debug is a function that simply writes out debugging statements to a >text file for me. > >Here is the output of the debug statement above: > >*** Wed Aug 17 03:45:13 2005 >ctx.locals.year=`'0238'` > >So, it looks to me like it is simply a string of four digits, namely, 0238 >and when I call ctx.get_value on the formfield "year", I get an exception. The above doesn't really fit with what's happening. Essentially ctx.get_value(name) looks like (with some irrelevent steps left out): def get_value(name): return eval(name, {}, self.locals.__dict__) Somehow "formfield" must be set to "0238", rather than "year". This is what should be happening: >>> locals={'year': '0238'} >>> eval('year', {}, locals) '0238' This is what it looks like is happening: >>> eval('0238', {}, locals) Traceback (most recent call last): File "", line 1, in ? File "", line 1 0238 ^ SyntaxError: invalid token -- Andrew McNamara, Senior Developer, Object Craft http://www.object-craft.com.au/ From tchur at optushome.com.au Wed Aug 17 18:21:18 2005 From: tchur at optushome.com.au (Tim Churches) Date: Wed, 17 Aug 2005 18:21:18 +1000 Subject: [albatross-users] Problem with ctx.get_value Message-ID: <200508170821.j7H8LId8014055@mail02.syd.optusnet.com.au> An embedded and charset-unspecified text was scrubbed... Name: not available URL: From sheila at thinkspot.net Fri Aug 19 16:58:38 2005 From: sheila at thinkspot.net (Sheila King) Date: Thu, 18 Aug 2005 23:58:38 -0700 Subject: [albatross-users] Problem with ctx.get_value In-Reply-To: <20050817080746.5EE2D6F4262@longblack.object-craft.com.au> References: <6277396C102E01BD52C499B2@[192.168.1.102]> <20050817062453.7F7EC6F4262@longblack.object-craft.com.au> <20050817080746.5EE2D6F4262@longblack.object-craft.com.au> Message-ID: <787D75A362373324FB2B711C@[192.168.1.102]> Thank you to both Andrew and Tim... --On Wednesday, August 17, 2005 6:07 PM +1000 Andrew McNamara wrote: > The above doesn't really fit with what's happening. Essentially > ctx.get_value(name) looks like (with some irrelevent steps left out): > > def get_value(name): > return eval(name, {}, self.locals.__dict__) > > Somehow "formfield" must be set to "0238", rather than "year". > > This is what should be happening: > > >>> locals={'year': '0238'} > >>> eval('year', {}, locals) > '0238' > > This is what it looks like is happening: > > >>> eval('0238', {}, locals) > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1 > 0238 > ^ > SyntaxError: invalid token Yes, apparently BOTH of the above are happening (I find, after delving a bit further into the code). Still not sure why. Of course, the second one is what is lousing it all up. Tim, thanks for the reminder about the octal. Now the error makes much more sense. I had done that eval('0238') in an interactive shell myself, and couldn't understand why it threw the error. Now I do. ;) Appreciate the assistance...digging into the code deeper now... Thanks! -- Sheila King sheila at thinkspot.net http://www.thinkspot.net/sheila/ From korg at darkqueen.org Mon Aug 29 10:13:40 2005 From: korg at darkqueen.org (Cameron Blackwood) Date: Mon, 29 Aug 2005 10:13:40 +1000 Subject: [albatross-users] Albatross for First Person Shooters... :) Message-ID: <20050829001340.069DE540DC@firewall.darkqueen.org> Hi everyone, I just throught that Id drop everyone a line to say that Im using albatross in the pyweek challange: http://www.mechanicalcat.net/tech/PyWeek/1 (The idea of the challange write a game in python in a week.) Im aiming for a web based (duh) strategy game and Im using albatross for my server/interface. So if you see any posts from me about 'how do I do XYZ' in the next week then you'll know why. :) Im writing a wrapper for albatross (becuase as I have previously posted in my periodic revisits to albatross that some bits are a little weird/hard to use). The wrapper (so far) takes a directory and examines all the .py files, looks for page classes, finds their templates and then registers them with the albatross app. Im just about to add a wrapper to the context's variable storage too to make global/local variables a bit clearer (atleast for me). Im also hoping to add easier handling of image and image maps, but Ill hit that when and if I need to. Anyway, hopefully it will be in a fit state to post by the end. (Couldnt get to sleep last night... was too busy thinking of ways to try and get game balance. hehehe. :) 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 ---------- I hope something GOOD came in the mail today so I have a REASON to live!!