Opened 18 years ago
Closed 18 years ago
#5443 closed (fixed)
Jython has no os.access (nor os.chmod)
| Reported by: | 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)
Change History (9)
by , 18 years ago
| Attachment: | jython_no_os_access.patch added |
|---|
comment:1 by , 18 years ago
| Has patch: | set |
|---|
comment:2 by , 18 years ago
| Triage Stage: | Unreviewed → Ready for checkin |
|---|
comment:3 by , 18 years ago
| Component: | django-admin.py → 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.
comment:4 by , 18 years ago
| Triage Stage: | Ready for checkin → Accepted |
|---|
comment:5 by , 18 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 , 18 years ago
| Triage Stage: | Accepted → 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)
comment:7 by , 18 years ago
| Keywords: | sprintsept14 added |
|---|
comment:8 by , 18 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
Simple patch