Django

Code

Changeset 6028

Show
Ignore:
Timestamp:
08/30/07 23:35:03 (1 year ago)
Author:
adrian
Message:

Fixed #5307 -- startproject/startapp now makes sure all files it creates are writeable. Thanks, Thomas Stromberg

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/AUTHORS

    r6004 r6028  
    259259    Thomas Steinacher <http://www.eggdrop.ch/> 
    260260    nowell strite 
     261    Thomas Stromberg <tstromberg@google.com> 
    261262    Sundance 
    262263    SuperJared 
  • django/trunk/django/core/management/base.py

    r6022 r6028  
    22from django.core.management.color import color_style 
    33import sys 
     4import os 
    45 
    56class CommandError(Exception): 
     
    122123def copy_helper(style, app_or_project, name, directory, other_name=''): 
    123124    import django 
    124     import os 
    125125    import re 
    126126    import shutil 
     
    158158            try: 
    159159                shutil.copymode(path_old, path_new) 
     160                _make_writeable(path_new) 
    160161            except OSError: 
    161162                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)) 
     163 
     164def _make_writeable(filename): 
     165    "Makes sure that the file is writeable. Useful if our source is read-only." 
     166    import stat 
     167    if not os.access(filename, os.W_OK): 
     168      st = os.stat(filename) 
     169      new_permissions = stat.S_IMODE(st.st_mode) | stat.S_IWUSR 
     170      os.chmod(filename, new_permissions) 
     171 
  • django/trunk/django/core/management/commands/startproject.py

    r5907 r6028  
    2929        main_settings_file = os.path.join(directory, project_name, 'settings.py') 
    3030        settings_contents = open(main_settings_file, 'r').read() 
    31  
    32         # If settings.py was copied from a read-only source, make it writeable. 
    33         if not os.access(main_settings_file, os.W_OK): 
    34             os.chmod(main_settings_file, 0600) 
    35  
    3631        fp = open(main_settings_file, 'w') 
    3732        secret_key = ''.join([choice('abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)') for i in range(50)])