[albatross-users] Problem with ctx.get_value

Sheila King sheila at thinkspot.net
Wed Aug 17 17:50:41 EST 2005


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 
<andrewm at object-craft.com.au> 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 "<string>", line 1
>>    0238
>>       ^
>> SyntaxError: invalid token
> --
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
>





More information about the Albatross-users mailing list