Status: New
Owner: ----
Labels: Type-Defect Priority-Medium
New issue 24 by gonzalosaavedra: [PATCH] Trying to acquire a lock fails if
the current working directory is not writable
http://code.google.com/p/django-mailer/issues/detail?id=24
In mailer.engine.send_all() a FileLock is created this way:
lock = FileLock("send_mail")
In FileLock.__init_(), os.path.abspath is used to get the absolute path to
that filename -- "on most platforms, this is equivalent to
normpath(join(os.getcwd(), path))" [1] -- so if the current working
directory is not writable this will raise a LockFailed exception.
Relying on the cwd its a bad idea for web aplication, as Graham Dumpleton
commented on django-users [2] some time ago, quoting him:
"Python web frameworks or applications which have to one degree or
another made a choice to somehow rely on the current working directory
being a specific value are limiting the deployment choices for their
users by doing so. You are thus highly discouraged against doing it
and using __file__ as an anchor or a variable setting in main settings
configuration file is a better and more portable way of doing it."
Trying to keep it simple I work around it making the path relative to the
app_dir using __file__. This worked for me but note that is not a perfect
solution, a setting to override this is needed for some setups.
Patch attached.
[1]: http://docs.python.org/library/os.path.html#os.path.abspath
[2]: http://groups.google.com/group/django-users/msg/51d3f6b6e5c382ba
Attachments:
app_dir_relative_lock.patch 593 bytes
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---