[albatross-users] Problem with ctx.get_value

Andrew McNamara andrewm at object-craft.com.au
Wed Aug 17 18:07:46 EST 2005


>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 "<stdin>", line 1, in ?
      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