Opened 17 years ago

Closed 17 years ago

#5443 closed (fixed)

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

Reported by: leo.soto@… Owned by: nobody
Component: contrib.admin Version: dev
Severity: Keywords: jython sprintsept14
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

jython_no_os_access.patch (838 bytes ) - added by leosoto <leo.soto@…> 17 years ago.
Simple patch

Download all attachments as: .zip

Change History (9)

by leosoto <leo.soto@…>, 17 years ago

Attachment: jython_no_os_access.patch added

Simple patch

comment:1 by leosoto <leo.soto@…>, 17 years ago

Has patch: set

comment:2 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:3 by Jacob, 17 years ago

Component: django-admin.pyAdmin 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.

comment:4 by Jacob, 17 years ago

Triage Stage: Ready for checkinAccepted

comment:5 by leosoto <leo.soto@…>, 17 years ago

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

comment:6 by Fredrik Lundh <fredrik@…>, 17 years ago

Triage Stage: AcceptedReady 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)

comment:7 by Fredrik Lundh <fredrik@…>, 17 years ago

Keywords: sprintsept14 added

comment:8 by Malcolm Tredinnick, 17 years ago

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top