http://code.google.com/p/modwsgi/wiki/ChangesInVersion0200
This refresh fixes a bug in WSGIPythonPath which would cause a crash
when used on some platforms, plus issues with thread stack size
configuration which made module not portable between Apache worker and
prefork MPMs.
The behaviour of WSGIPythonPath has also changed from 2.0c1 in that
its value is not inherited by daemon processes. Instead you need to
separately use 'python-path' option for WSGIDaemonProcess to specify
additional Python module directories for daemon processes.
Also added new WSGIPythonEggs directive and corresponding
'python-eggs' option for WSGIDaemonProcess to specify Python Egg cache
directory. This serves the same role as having set PYTHON_EGG_CACHE
directive environment variable.
Finally, the WSGIPythonExecutable directive has been removed. This
didn't work on Windows or MacOSX as wasn't really being used as
intended. If it is necessary to override where a Python installation
is, the WSGIPythonHome directive should be used instead.
The combination of using WSGIPythonHome and the WSGIPythonPath
directive or 'python-path' option for daemon processes should make it
much easier to use mod_wsgi with Python virtual environments.
Enjoy.
Graham
[Fri Nov 09 01:13:48 2007] [info] mod_wsgi (pid=6099): Adding '/home/
gert/www/trunk/wsgi' to path.
[Fri Nov 09 01:13:48 2007] [info] [client 192.168.1.18] mod_wsgi
(pid=6099, process='', application='localhost|/upload/servlet'):
Loading WSGI
[Fri Nov 09 01:13:49 2007] [error] [client 192.168.1.18] mod_wsgi
(pid=6099): Exception occurred processing WSGI script '/home/gert/www/
trunk/
[Fri Nov 09 01:13:49 2007] [error] [client 192.168.1.18] TypeError:
sequence of string values expected, value of type array.array found,
refer
[Fri Nov 09 01:14:00 2007] [info] mod_wsgi (pid=6183): Create
interpreter 'localhost|/download/servlet'.
[Fri Nov 09 01:14:00 2007] [info] mod_wsgi (pid=6183): Adding '/home/
gert/www/trunk/wsgi' to path.
[Fri Nov 09 01:14:00 2007] [info] [client 192.168.1.18] mod_wsgi
(pid=6183, process='', application='localhost|/download/servlet'):
Loading WS
[Fri Nov 09 01:14:00 2007] [error] [client 192.168.1.18] mod_wsgi
(pid=6183): Exception occurred processing WSGI script '/home/gert/www/
trunk/
[Fri Nov 09 01:14:00 2007] [error] [client 192.168.1.18] TypeError:
sequence of string values expected, value of type array.array found
A WSGI application is meant to return an iterable value where the
yielded values must only be strings. You seem to be returning an
iterable that contains an 'array.array' object instance.
The simplest example of an iterable is a list. Ie.,
[ "string1", "string2", "string3" ]
Your code appears to be returning:
[ array.array('c', 'string1') ]
which will be rejected.
What is your code trying to do? Why are you using 'array' module?
Graham
On Nov 9, 1:49 am, "Graham Dumpleton" <graham.dumple...@gmail.com>
wrote:
It don't know :) I didn't change code only mod_wsgi
This all my code
http://appwsgi.googlecode.com/svn/trunk/wsgi/
Is it returning image data from PIL, or something from an XML library,
from a database, or from some other source?
Ie., what is generating the data being returned as obviously some
third party module you are using is generating it and you haven't
ensured you use str() to convert it back to a string object.
Graham
On 09/11/2007, gert <gert.c...@gmail.com> wrote:
>
>
>
Regards,
Max.
first when downloading a image from mysql i get a empty file text/x-
python file instead of a png file ? So i assume one of the errors is
from my download.py
second error is from session.py that doesn't seem to get my cookie on
my web browser resulting in my self made permission denied alert
trying to aces data with out my cookie that i did not get properly
I don't get 500 error's only weird stuff that i do not have on my
windows pc with the same source code
So i probably mest up my source code somehow on my ubunut pc, i will
check again
On Nov 9, 2:25 am, "Graham Dumpleton" <graham.dumple...@gmail.com>
wrote:
> But what is the specific URL you are accessing which is causing this
> error returning?
>
> Is it returning image data from PIL, or something from an XML library,
> from a database, or from some other source?
>
> Ie., what is generating the data being returned as obviously some
> third party module you are using is generating it and you haven't
> ensured you use str() to convert it back to a string object.
>
> Graham
>
As per the 2.0 change notes it has been removed.
This didn't work on Windows and MacOSX and was being used by people as
a mechanism for doing virtual environments when it was only intended
as a fail safe to get around issues with multiple versions of Python
being installed on a box. The same thing could be done though in a
much better way using WSGIPythonHome, so rather than provide two ways
of doing the same thing, albeit where one only works on some systems,
I cut it back to one way to avoid confusion.
So, if you had Python installed in /usr/local/bin/pythonX.Y, whereby
the Python lib directory was /usr/local/lib/pythonX.Y, instead of
using:
WSGIPythonExecutable /usr/local/bin/pythonX.Y
use:
WSGIPythonHome /usr/local
The WSGIPythonExecutable directive was only ever used as an anchor
point by Python to work out what WSGIPythonHome indicates explicitly.
That is, what Python was doing to calculate the Python prefix
directory from WSGIPythonExecutable was to go:
os.path.join(os.path.dirname(os.path.dirname(path)), 'lib', 'pythonX.Y')
Note that WSGIPythonHome was in mod_wsgi 1.0 and will work there as well.
If for some reason WSGIPythonHome doesn't achieve the same affect, do
let me know, as have only disabled the WSGIPythonExecutable code or
now and haven't actually removed it. You should be able to do the same
thing with WSGIPythonHome though.
When I get a chance I intend blogging about
WSGIPythonHome/WSGIPythonPath and how to use it with virtual
environments.
Graham
snif every time you think your are finally done crap happens...
PKGBUILD for Archlinux is updated :
http://aur.archlinux.org/packages.php?do_Details=1&ID=13521
Nicolas
upgraded my ubuntu to gusty including a new mysql python apache and
now without changing code my file uploads seem to work again, only my
cookie is still not doing the same on windows.
Seems like there are other things to consider when writing wsgi code?
Wait a minute i do a time check in my sql statements so i think it has
to do with the hole UTC GMT time stuff and my cookie get rejected
because it is expired.
Ubuntu = UTC
Windows = GMT
No scratch that cookies are exactly the same....
Is there something different with environ.get('HTTP_COOKIE','') in
2.0c2 ? or on linux and windows ?
oops :) i found it i didn't set my gid column to 1
could you _please_ stop talking to yourself on the list?
Thanks.
--
Bernd Zeimetz
<be...@bzed.de> <http://bzed.de/>
As ftp-master.debian.org is still broken down due to a massive hardware
failure there's no way to update the Debian package yet.
If somebody is interested I can provide a package or at least the
sources you need to build the .deb by yourself.
Changes required to compile: at line 3012 the following code needs to
be deleted:
struct passwd *pwent;
pwent = getpwuid(geteuid());
So you just deleted some Graham code without putting anything in
return and it still works ? windows is something amazing isn't it :)
PS can you compile it for 64 bit too ?
Sorry, no 64 bit builds :( Too much of a hassle.
* Apache2 has detected a syntax error in your configuration files:
Syntax error on line 151 of /etc/apache2/vhosts.d/vhosts.conf:
WSGIPythonHome cannot occur within <VirtualHost> section
What if I have project that depends on python2.5 installed in custom
path and all other projects using system wide python? This is my exact
situation.
I would like to define this on VirtualHost level.
Please advise.
Regards,
Please disregard my previous post. It does not work :-)
I have somple wsgi script below. Apache has the following conf.
directives:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIPythonOptimize 2
WSGIPythonHome /home/asterisk/python2.5
snowflake ~ # ls /home/asterisk/python2.5
bin include lib man
snowflake ~ # ls /home/asterisk/python2.5/bin/python
/home/asterisk/python2.5/bin/python
snowflake ~ #
When I run it I get:
[Sat Nov 10 10:34:59 2007] [debug] mod_wsgi.c(7147): mod_wsgi
(pid=26733): Starting thread 4 in daemon process 'hvpn'.
[Sat Nov 10 10:34:59 2007] [debug] mod_wsgi.c(7147): mod_wsgi
(pid=26733): Starting thread 5 in daemon process 'hvpn'.
[Sat Nov 10 10:34:59 2007] [info] mod_wsgi (pid=26734): Create
interpreter 'hvpnxxx.com|'.
[Sat Nov 10 10:34:59 2007] [info] [client 195.242.215.60] mod_wsgi
(pid=26734, process='hvpn', application='vpnxxx.com|'): Loading WSGI
script '/home/asterisk/rmanager/web-script/wsgi_app.py'.
[Sat Nov 10 10:34:59 2007] [error] [client 195.242.215.60] mod_wsgi
(pid=26734): Target WSGI script '/home/asterisk/rmanager/web-script/
wsgi_app.py' cannot be loaded as Python module.
[Sat Nov 10 10:34:59 2007] [error] [client 195.242.215.60] mod_wsgi
(pid=26734): Exception occurred processing WSGI script '/home/asterisk/
rmanager/web-script/wsgi_app.py'.
[Sat Nov 10 10:34:59 2007] [error] Traceback (most recent call last):
[Sat Nov 10 10:34:59 2007] [error] File "/home/asterisk/rmanager/web-
script/wsgi_app.py", line 1, in ?
[Sat Nov 10 10:34:59 2007] [error] import os, sys
[Sat Nov 10 10:34:59 2007] [error] *ImportError: No module named os*
If I compile mod_wsgi --with-python /home/asterisk/python2.5/bin/
python all works ok.
If I set WSGIPythonHome to non-existent directory I get same error "No
module named os".
So it seems that mod_wsgi loads python binary from path found at
compilation time. So in my case it picks up python2.4 and when set
WSGIPythonHome it tries to load os module from 2.5!
My script:
import os, sys
sys.path.append('/home/asterisk/rmanager') # should be set in
WSGIPythonPath instead.
os.environ['DJANGO_SETTINGS_MODULE'] = 'rmanager.settings'
#XXX: add logging to r manager
# WSGI app is not allowed to write to stdout.
sys.stdout = sys.stderr
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
import os, sys
#sys.path.append('/home/asterisk/rmanager')
os.environ['DJANGO_SETTINGS_MODULE'] = 'rmanager.settings'
and add WSGIPythonPath /home/asterisk/rmanager to http.conf I get:
[Sat Nov 10 10:53:05 2007] [error] [client x..x.x. EnvironmentError:
Could not import settings 'rmanager.settings' (Is it on sys.path? Does
it have syntax errors?): No module named rmanager.settings
So seems WSGIPythonPath is not doing its job.
Regards,
Max.
Riscking to say something stupid again, does this work ?
import os, sys, rmanager
os.environ['DJANGO_SETTINGS_MODULE'] = rmanager.settings
You _have_ to build mod_wsgi using the python version you're using for
your applications. Using a different version and setting the home
directory to some other version can't work.
uploaded a few minutes ago, should hit experimental soon.