First, you can install and use higher versions of Spyce with the older
Apache. The config files are not sufficiently different to cause any
problems. In other words, you can use the 'rpm --nodeps' switch to
install the new package on your system, and it should work. Please let
me know if this is not the case. I have modified the dependency in the
rpm to the new Apache, because that's what most people are now using.
There have been quite a number of fixes and improvements since v1.3.9.
Now, back to your original question. It's not a Spyce bug. The problem
is that you are running an old mod_python with a new Python. More
specifically, as of Python 2.2, we have iterator types. These are
explained in the Python documentation:
Standard Python dictionaries are iterable. In other words, they have an
__iter__() method that returns an iterator object.
For example, if you write:
you will see this __iter__() method.
Under Spyce, you get your CGI environment from request.env(). Spyce, in
turn, gets this information from a number of possible sources, depending
on how it is running. Under mod_python, we get our CGI-like environment
from mod_python. Under FCGI, we get it from the FCGI library. Under the
Spyce webserver, we generate it ourselves from the incoming request
(like Apache does). Under CGI, we get it from the actual process, using
os.environ(). etc. There are different "adapters" over which the core
Spyce engine operates.
Back to mod_python... Under mod_python, we get the CGI information from
the mod_python request object, from a member called 'subprocess_env'.
This object is not a standard Python dictionary. Rather, it's a
mod_python type called a table. See:
So, if you write, in your Spyce script:
[[ print dir(request.env()) ]]
you will be seeing the methods exposed by the environment object.
Running under CGI, you will see the __iter__() method. Under the old
mod_python, you will not. The mod_python table object does not support
iteration. The new mod_python (v3.0) table object does. See:
So, under the new mod_python all works well. Incidentally, this is why I
was not able to replicate your problem.
Spyce *could* wrap the old mod_python table object within an object that
does support iteration. I don't have the time to implement this, just to
support the old mod_python. Please use the old mod_python with older
Python libraries that don't utilize iteration. The Python 2.2 libraries
seem to have a different, older cgi.py that do not perform iteration
over the environment parameter. You should know that there are also
other known issues with mod_python 2.7.8 and Python 2.3. For example:
Alternatively, just use the new mod_python. The development of the old
mod_python seems to be basically mostly frozen, as is the older Apache.
If you'd like to patch the mod_python adapter in the spyceModpy.py file
to wrap the CGI-like table object with an iterable object, I'll happily
incorporate it. In any case, now you know where the error is coming
In general, Spyce has not been tested much under Python 2.3 yet. I'm not
sure how many people already use v2.3 in production environments. For
that matter, I'm not sure how many people still use v1.5.2. It's
becoming cumbersome to function across all these increasingly divergent
versions, and it's not clear that the effort is warranted.
All the best,
On Mon, 12 Jan 2004, [ISO-8859-1] Dagur P=E1ll Ammendrup wrote:
>This is what it returns:
>My Python version is: 2.3.2 (#1, Nov 21 2003, 23:20:37) [GCC 2.96
>20000731 (Red Hat Linux 7.3 2.96-113)]
>I'm using spyce 1.3.9-1 (because I'm using apache 1.3.x) and I installed
>Rimon Barr wrote:
>>From the exception trace, you can see that the error is actually
>> >/usr/local/lib/python2.3/cgi.py:442, in __init__:
>>on the following code:
>> >if 'REQUEST_METHOD' in environ:
>>Is it possible that you are running an older version of the Python
>>interpreter with newer class libraries? In your Spyce script, try to
>>insert the following lines, and run it again:
>> import sys
>> print 'My Python version is:', sys.version
>>You'll be able to see which version of the Python interpreter you are
>>running. If it's not showing 2.3 in the output, that's your problem.
>>If it is v2.3, then... Well, let's cross that bridge if we get to it.
>>All the best,
>>On Mon, 12 Jan 2004, [ISO-8859-1] Dagur P?ll Ammendrup wrote:
>>>Spyce seems to work fine but when I try to get input with POST or GET I
>>>get an error.
>>>TypeError: iterable argument required
>>>*Stack:* handler.spy:12, in (main):
>>>stuff =3D request.post1()
>>>/usr/share/spyce/modules/request.py:129, in post1:
>>>/usr/share/spyce/modules/request.py:101, in _postInit:
>>>self._postfields =3D cgi.FieldStorage(fp=3Dself._api.getRequest(),
>>>/usr/local/lib/python2.3/cgi.py:442, in __init__:
>>>if 'REQUEST_METHOD' in environ:
>>>(http://www.apexnews.net/blog/post.spy) If you want to try it out.
>>>Here is the source:
>>>template =3D '''
>>><img src=3D"/blog/%(image)s" alt=3D"PIC HERE"/>%(main)s
>>>stuff =3D request.post1()
>>>output =3D template % stuff