Django

Code

Ticket #5443 (closed: fixed)

Opened 1 year ago

Last modified 1 year ago

Jython has no os.access (nor os.chmod)

Reported by: leo.soto@gmail.com Assigned to: nobody
Milestone: Component: Admin interface
Version: SVN Keywords: jython sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The Java platform has no uniform concept of permissions, so Jython don't offer functions such as os.access() or os.chmod(). So Django should avoid checking permissions when running on Jython.

Attachments

jython_no_os_access.patch (0.8 kB) - added by leosoto <leo.soto@gmail.com> on 09/14/07 01:09:28.
Simple patch

Change History

09/14/07 01:09:28 changed by leosoto <leo.soto@gmail.com>

  • attachment jython_no_os_access.patch added.

Simple patch

09/14/07 01:15:43 changed by leosoto <leo.soto@gmail.com>

  • needs_better_patch changed.
  • has_patch set to 1.
  • needs_tests changed.
  • needs_docs changed.

09/14/07 17:34:28 changed by Simon G. <dev@simon.net.nz>

  • stage changed from Unreviewed to Ready for checkin.

09/14/07 17:43:24 changed by jacob

  • component changed from django-admin.py to Admin interface.

Does os.access not work on Jython, or is it just missing entirely? If it's missing, I'd much rather catch an AttributeError ("better to ask forgiveness than permission"). Please verify one way or the other and I'll check this in.

09/14/07 17:43:32 changed by jacob

  • stage changed from Ready for checkin to Accepted.

09/14/07 21:28:08 changed by leosoto <leo.soto@gmail.com>

Jacob: it's missing entirely. But I don't quite like to wrap the entire catching AttributeError?, as it could hide real errors.

09/15/07 05:39:44 changed by Fredrik Lundh <fredrik@pythonware.com>

  • stage changed from Accepted to Ready for checkin.

Straight-forward patch. Possible alternative:

def _make_writeable(filename):
    "Makes sure that the file is writeable. Useful if our source is read-only."
    import stat
    if sys.platform.startswith('java'):
        return # On Jython there is no os.access() 
    if not os.access(filename, os.W_OK):
	st = os.stat(filename)
	new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR
	os.chmod(filename, new_permissions)

09/15/07 05:40:28 changed by Fredrik Lundh <fredrik@pythonware.com>

  • keywords changed from jython to jython sprintsept14.

09/15/07 06:19:50 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [6281]) Fixed #5443 -- Handle lack of os.access() and os.chmod() in Jython. Thanks, Leo Soto.


Add/Change #5443 (Jython has no os.access (nor os.chmod))




Change Properties
Action