Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
GoogleCodeExporter opened this issue Mar 28, 2015 · 11 comments

Comments

Projects
None yet
1 participant
@GoogleCodeExporter
Copy link

commented Mar 28, 2015

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

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Just confirmed this still occurs in GAE 1.1.3

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

[deleted comment]
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

@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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

@gvanrossum - Thanks a lot. That works for me.

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Here we go! as attach!

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

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

@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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

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

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

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

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.