[albatross-users] Problem with ctx.get_value
Sheila King
sheila at thinkspot.net
Wed Aug 17 15:47:13 EST 2005
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 "<string>", 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/
More information about the Albatross-users
mailing list