mirror of https://github.com/django/django.git
Fixed #5307 -- startproject/startapp now makes sure all files it creates are writeable. Thanks, Thomas Stromberg
git-svn-id: http://code.djangoproject.com/svn/django/trunk@6028 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
33ab65dd1e
commit
d09d1428f8
1
AUTHORS
1
AUTHORS
|
@ -258,6 +258,7 @@ answer newbie questions, and generally made Django that much better:
|
||||||
Vasiliy Stavenko <stavenko@gmail.com>
|
Vasiliy Stavenko <stavenko@gmail.com>
|
||||||
Thomas Steinacher <http://www.eggdrop.ch/>
|
Thomas Steinacher <http://www.eggdrop.ch/>
|
||||||
nowell strite
|
nowell strite
|
||||||
|
Thomas Stromberg <tstromberg@google.com>
|
||||||
Sundance
|
Sundance
|
||||||
SuperJared
|
SuperJared
|
||||||
Radek Švarz <http://www.svarz.cz/translate/>
|
Radek Švarz <http://www.svarz.cz/translate/>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.core.exceptions import ImproperlyConfigured
|
from django.core.exceptions import ImproperlyConfigured
|
||||||
from django.core.management.color import color_style
|
from django.core.management.color import color_style
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
class CommandError(Exception):
|
class CommandError(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -121,7 +122,6 @@ class NoArgsCommand(BaseCommand):
|
||||||
|
|
||||||
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
def copy_helper(style, app_or_project, name, directory, other_name=''):
|
||||||
import django
|
import django
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
other = {'project': 'app', 'app': 'project'}[app_or_project]
|
other = {'project': 'app', 'app': 'project'}[app_or_project]
|
||||||
|
@ -157,5 +157,15 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
|
||||||
fp_new.close()
|
fp_new.close()
|
||||||
try:
|
try:
|
||||||
shutil.copymode(path_old, path_new)
|
shutil.copymode(path_old, path_new)
|
||||||
|
_make_writeable(path_new)
|
||||||
except OSError:
|
except OSError:
|
||||||
sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
|
sys.stderr.write(style.NOTICE("Notice: Couldn't set permission bits on %s. You're probably using an uncommon filesystem setup. No problem.\n" % path_new))
|
||||||
|
|
||||||
|
def _make_writeable(filename):
|
||||||
|
"Makes sure that the file is writeable. Useful if our source is read-only."
|
||||||
|
import stat
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,6 @@ class Command(LabelCommand):
|
||||||
# Create a random SECRET_KEY hash, and put it in the main settings.
|
# Create a random SECRET_KEY hash, and put it in the main settings.
|
||||||
main_settings_file = os.path.join(directory, project_name, 'settings.py')
|
main_settings_file = os.path.join(directory, project_name, 'settings.py')
|
||||||
settings_contents = open(main_settings_file, 'r').read()
|
settings_contents = open(main_settings_file, 'r').read()
|
||||||
|
|
||||||
# If settings.py was copied from a read-only source, make it writeable.
|
|
||||||
if not os.access(main_settings_file, os.W_OK):
|
|
||||||
os.chmod(main_settings_file, 0600)
|
|
||||||
|
|
||||||
fp = open(main_settings_file, 'w')
|
fp = open(main_settings_file, 'w')
|
||||||
secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
|
secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])
|
||||||
settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents)
|
settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents)
|
||||||
|
|
Loading…
Reference in New Issue