Hello,
I have come across an issue and I think it's a mod_wsgi issue.
First my setup:
Apache 2.2.14, mod_wsgi 3.3, python 2.6.5, django 1.3.1 on
Ubuntu Lucid 64.
I have a view which gets, with POST, a directory name, in order to create it.
After all the necessary security checks, the code is something like this:
PATH = '/home/andreas'
newDir = os.path.join(PATH, name)
if not os.path.exists(newDir):
os.mkdir(newDir)
When name is a latin only characters string everything is fine,
but when name is unicode I am getting exceptions.
os.path.join works with no problem and newDIr is tested with:
>>type(newDir) is unicode
True
os.path.exists complains about : ascii codec can't decode etc....
when changed to: os.path.exists(u'%r'%newDir) it worked with no exceptions.
( strangely os.path.exists(unicode(newDir)) gives the same "ascii codec" exception !! )
os.mkdir does not work at all:
without any conversion it raises "ascii codec..."
with os.mkdir(u'%r'%newDir) it raises: "[Error 2]: Cannot find directory /home/andreas/τεστ" <-greek letters
(this is mkdir, it's not supposed to find it !!!)
Testing the above with the development server works flawlessly.
Also with cherrypy as a wsgi server everything runs ok.
That's why I have come to believe this is an apache+mod_wsgi problem.
But how can mod_wsgi change the behavior of a python function completely?
(Needless to say, when using the exact same commands at a python shell everything runs smoothly.)
Thank you for your time reading this.
If you need other tests, please let me know. I would be glad to help figuring this out.
Best regards,
Andreas
PS
django is started with graham's script:
http://blog.dscpl.com.au/2010/03/improved-wsgi-script-for-use-with.html