Koulio / rietveld

Automatically exported from code.google.com/p/rietveld
Apache License 2.0
0 stars 0 forks source link

Django fails to load on Windows with "AttributeError: 'module' object has no attribute 'unlink'" #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Install Python 2.5.2 on Windows (XP in my case)
2. Setup PATHs, etc for GAE
3. Run rietveld.py serve (or any other method of starting rietveld)
4. Navigate to http://localhost:<port>/

What is the expected output? What do you see instead?

I expect it to load the Issues list as per normal.
Instead, I get the exception as listed in the Issue summary

What version of the product are you using? On what operating system?

GAE 1.1.2, latest trunk of rietveld (revision 311)

Please provide any additional information below.

Basically it's due to Django's use of os.unlink in 
django/core/files/temp.py, line 34

When the django module is imported in rietveld/main.py, this line throws 
because os.unlink is not available in GAE.

This could be solved either by patching Django to check for the existence 
of os.unlink (arguably a bit overkill for such an obscure situation), or by 
making it a noop in rietveld.

Attached is a patch for the latter. This solves the issue for me.

Original issue reported on code.google.com by michael....@gmail.com on 16 Sep 2008 at 6:11

Attachments:

GoogleCodeExporter commented 9 years ago
Just confirmed this still occurs in GAE 1.1.3

Original comment by michael....@gmail.com on 16 Sep 2008 at 6:21

GoogleCodeExporter commented 9 years ago
Please report this to the Django folks.  They would like to be able to run 
without a
writable filesystem.

I suspect that if you patch os.unlink() to be a no-op, something else will fail,
because it's probably unlinking in anticipation of writing a temp file, which 
will
also fail...

Original comment by gvanrossum@gmail.com on 16 Sep 2008 at 2:23

GoogleCodeExporter commented 9 years ago
OK, no probs - I'm not sure of the best way to go about it - just checking for 
the 
presence (or lack thereof) of os.unlink works fine, but I don't know if there's 
a 
better way to deal with a non-writable filesystem as a whole.

I've created a ticket (and patch) at Django here:

http://code.djangoproject.com/ticket/9115

Original comment by michael....@gmail.com on 17 Sep 2008 at 12:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I am trying to write a webapp which does an urllib.urlopen to an outside URL. 
And as
it appears, urllib - like django - tries to use os.unlink. here is part of the 
stack
trace:

f = urllib.urlopen(self.fURL,postData)
File "/usr/lib64/python2.5/urllib.py", line 77, in urlopen
opener = FancyURLopener()
File "/usr/lib64/python2.5/urllib.py", line 609, in __init__
URLopener.__init__(self, *args, **kwargs)
File "/usr/lib64/python2.5/urllib.py", line 123, in __init__
self.__unlink = os.unlink # See cleanup()
AttributeError: 'module' object has no attribute 'unlink'

Original comment by jayeshsa...@gmail.com on 24 Oct 2008 at 4:37

GoogleCodeExporter commented 9 years ago
@jayeshsalvi - don't use urllib, use google.appengine.api.urlfetch.  See
http://code.google.com/appengine/docs/urlfetch/

Original comment by gvanrossum@gmail.com on 24 Oct 2008 at 5:43

GoogleCodeExporter commented 9 years ago
@gvanrossum - Thanks a lot. That works for me.

Original comment by jayeshsa...@gmail.com on 25 Oct 2008 at 2:56

GoogleCodeExporter commented 9 years ago
Here we go! as attach!

Original comment by guiyang...@gmail.com on 13 Jan 2009 at 3:25

Attachments:

GoogleCodeExporter commented 9 years ago
@guiyang923: Sorry, we can't accept patches to Django here.  Please comment on 
the
Django ticket already created: http://code.djangoproject.com/ticket/9115

Original comment by gvanrossum@gmail.com on 13 Jan 2009 at 3:40

GoogleCodeExporter commented 9 years ago
It looks like GAE 1.3.6 contains fake os.unlink in dev_appserver.py, so I guess 
this issue can be closed now.

Original comment by techtonik@gmail.com on 26 Aug 2010 at 6:06

GoogleCodeExporter commented 9 years ago
Seems to be resolved: 
http://groups.google.com/group/codereview-discuss/msg/afb1699a16ee903d

Original comment by albrecht.andi on 27 Aug 2010 at 12:50