Decouple 'uploaded/images' location from MEDIA_ROOT setting
Updated 1 month, 3 weeks ago
| Chris Lamb | Reviewers | ||
| reviewboard | |||
| None | Review Board SVN | ||
Adds 'UPLOADS_ROOT' configuration variable which decouples the 'uploaded/images' location from a being a suffix of MEDIA_ROOT. This allows the upload directory to be overridden in local_settings.py, allowing multiple instances of Review Board on a system to share a system-wide installation containing the htdocs and media directories (ie. in the context of distributor packages). For example, HTDOCS_ROOT and MEDIA_ROOT may point somewhere within /var/lib/ or /usr/share/, whilst a particular instance's UPLOAD_ROOT would point to (say) /srv/mysite.tld/uploads/ This change does not affect existing installations. This diff additionally modifies the "chown" call to use ":" (colon) as the USER:GROUP seperator over the deprecated "." (period).
Tested locally with my (draft) Debian packages.
Diff revision 2 (Latest)
|
1
2
|
|
|
1
2
|
- /trunk/reviewboard/settings.py: 1 change [ 1 ]
- /trunk/reviewboard/test.py: 1 change [ 1 ]
- /trunk/reviewboard/admin/checks.py: 2 changes [ 1 2 ]
- /trunk/reviewboard/templates/admin/manual-updates/media-upload-dir.html: 4 changes [ 1 2 3 4 ]
| /trunk/reviewboard/settings.py | |||
|---|---|---|---|
| Revision 1440 | New Change | ||
| ... | 58 lines hidden [Expand] | ||
| 59 | 59 | ||
| 60 | REVIEWBOARD_ROOT = os.path.abspath(os.path.split(__file__)[0]) |
60 | REVIEWBOARD_ROOT = os.path.abspath(os.path.split(__file__)[0]) |
| 61 | 61 | ||
| 62 | HTDOCS_ROOT = os.path.join(REVIEWBOARD_ROOT, 'htdocs') |
62 | HTDOCS_ROOT = os.path.join(REVIEWBOARD_ROOT, 'htdocs') |
| 63 | MEDIA_ROOT = os.path.join(HTDOCS_ROOT, 'media') |
63 | MEDIA_ROOT = os.path.join(HTDOCS_ROOT, 'media') |
| 64 | UPLOADS_ROOT = os.path.join(MEDIA_ROOT, 'uploaded') |
||
| 64 | 65 | ||
| 65 | # where is the site on your server ? - add the trailing slash. |
66 | # where is the site on your server ? - add the trailing slash. |
| 66 | SITE_ROOT = '/' |
67 | SITE_ROOT = '/' |
| 67 | 68 | ||
| 68 | TEMPLATE_DIRS = ( |
69 | TEMPLATE_DIRS = ( |
| ... | 131 lines hidden [Expand] | ||
| /trunk/reviewboard/test.py | |||
|---|---|---|---|
| Revision 1440 | New Change | ||
| ... | 55 lines hidden [Expand] | ||
| 56 | 56 | ||
| 57 | # Default to testing in a non-subdir install. |
57 | # Default to testing in a non-subdir install. |
| 58 | settings.SITE_ROOT = "/" |
58 | settings.SITE_ROOT = "/" |
| 59 | settings.MEDIA_ROOT = "/tmp/reviewboard-tests" |
59 | settings.MEDIA_ROOT = "/tmp/reviewboard-tests" |
| 60 | 60 | ||
| 61 | images_dir = os.path.join(settings.MEDIA_ROOT, "uploaded", "images") |
61 | images_dir = os.path.join(settings.UPLOADS_ROOT, "images") |
| 62 | 62 | ||
| 63 | if not os.path.exists(images_dir): |
63 | if not os.path.exists(images_dir): |
| 64 | os.makedirs(images_dir) |
64 | os.makedirs(images_dir) |
| 65 | 65 | ||
| 66 | settings.MEDIA_URL = settings.SITE_ROOT + 'media/' |
66 | settings.MEDIA_URL = settings.SITE_ROOT + 'media/' |
| ... | 34 lines hidden [Expand] | ||
| /trunk/reviewboard/admin/checks.py | |||
|---|---|---|---|
| Revision 1440 | New Change | ||
| ... | 16 lines hidden [Expand] | ||
| 17 | 17 | ||
| 18 | if not _updates_required and not _install_fine: |
18 | if not _updates_required and not _install_fine: |
| 19 | # Check if there's a media/uploaded/images directory. If not, this is |
19 | # Check if there's a media/uploaded/images directory. If not, this is |
| 20 | # either a new install or is using the old-style media setup and needs |
20 | # either a new install or is using the old-style media setup and needs |
| 21 | # to be manually upgraded. |
21 | # to be manually upgraded. |
| 22 | uploaded_dir = os.path.join(settings.MEDIA_ROOT, "uploaded") |
22 | uploaded_dir = os.path.join(settings.UPLOADS_ROOT) |
| 23 | 23 | ||
| 24 | if not os.path.isdir(uploaded_dir) or \ |
24 | if not os.path.isdir(uploaded_dir) or \ |
| 25 | not os.path.isdir(os.path.join(uploaded_dir, "images")): |
25 | not os.path.isdir(os.path.join(uploaded_dir, "images")): |
| 26 | _updates_required.append(( |
26 | _updates_required.append(( |
| 27 | "admin/manual-updates/media-upload-dir.html", { |
27 | "admin/manual-updates/media-upload-dir.html", { |
| 28 | 'MEDIA_ROOT': settings.MEDIA_ROOT |
28 | 'UPLOADS_ROOT': settings.UPLOADS_ROOT |
| 29 | } |
29 | } |
| 30 | )) |
30 | )) |
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | # |
33 | # |
| ... | 20 lines hidden [Expand] | ||
- /trunk/reviewboard/settings.py: 1 change [ 1 ]
- /trunk/reviewboard/test.py: 1 change [ 1 ]
- /trunk/reviewboard/admin/checks.py: 2 changes [ 1 2 ]
- /trunk/reviewboard/templates/admin/manual-updates/media-upload-dir.html: 4 changes [ 1 2 3 4 ]
Other reviews