[albatross-users] Python 2.4.1 incompatibility with al-for ?

Sheila King sheila at thinkspot.net
Wed Apr 20 16:23:01 EST 2005


OK, I am really at my wits end now.

I've broken this down to an extremely simple template...here is the entire 
file:

-------
<html><head><title>Test</title></head>
<body>
Text
<al-for iter="entry" expr="_loglist" pagesize="50" prepare/>

</body>
</html>
-------

My _loglist is as follows:

>>> ctx.locals._loglist
['2005-04-19: Technical Email Address updated<br /><b>From</b>: <br 
/><b>To:</b> root at kserver.org']

It is actually a list with a single string in it (for testing purposes this 
is what I am using, but in actual live use there would probably be a list 
of several strings).

The suggestion to investigate what the MySQLdb module was returning 
(perhaps a different type of object), which sounded like a good lead to 
check, actually turns out to be a non-issue. Both MySQLdb return the exact 
same results and types and objects (all tested from command line).

And as noted previously, the extremely simple template shown above runs 
without error under Python 2.2.2 but under 2.4.1 it repeatedly causes an 
error which is (as far as I can see) failure to produce any output from the 
CGI process, resulting in "premature end of script headers" as the logged 
error message from the web server.

I also ran the same template from the command line, and from command line 
it works just fine under both Pythons. ARRRGH.

Mind you, I'm using SimpleContext when running it from command line. In my 
CGI app I use the Session File context. But when I tried to run that from 
the command line, it had too many missing environment variables and I got 
frustrated with trying to make that work and switched to SimpleContext.

I am so lost as to where to go or what to try next. :/

-- 
Sheila King
sheila at thinkspot.net
http://www.thinkspot.net/sheila/


--On Tuesday, April 19, 2005 6:59 AM -0700 Sheila King 
<sheila at thinkspot.net> wrote:

> Hello Andrew,
>
> Thanks for the suggestions...
>
> --On Tuesday, April 19, 2005 8:25 PM +1000 Andrew McNamara
> <andrewm at object-craft.com.au> wrote:
>
>>> Maybe the mysql library was upgraded when you went
>>> from 2.2 to 2.4?
>
> This is probably true. I will check with the package maintainer for our
> server to be sure...
>
>>> My guess would be that it's returning an iterable,
>>> rather than an array.
>
> I will check it out. What's strange is that I use <al-for> tags on a
> number of pages in the app, but most of them work fine.
>
> I've found another page that is throwing an error although it doesn't go
> to 500 Internal Server error...probably because I'm catching the error on
> that page. I will have to investigate what the difference is between the
> pages where al-for works and where it doesn't, and it does sound like
> starting with the objects MySQL is returning is the next logical place to
> look. I believe on the pages where it works, I am constructing my own
> lists and not directly using the object returned by MySQLdb.
>
> Thank you again for the pointer on where to look next...
>
> --
> Sheila King
> sheila at thinkspot.net
> http://www.thinkspot.net/sheila/
>
>
>>> Currently <al-for> requires an indexable object
>>> such as an array or tuple. I guess you could try something like:
>>
>> It might also be worth trying to cast the object returned by mysql to a
>> list explicitly:
>>
>>     if result:
>>         ctx.locals._loglist = list(c.fetchone()['changelog'])
>>
>> --
>> Andrew McNamara, Senior Developer, Object Craft
>> http://www.object-craft.com.au/
>>
>
>
> _______________________________________________
> Albatross-users mailing list
> Albatross-users at object-craft.com.au
> https://www.object-craft.com.au/cgi-bin/mailman/listinfo/albatross-users
>





More information about the Albatross-users mailing list