From 8117acaca11c072ad1793b99f0dd9a441eaae957 Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 17 Apr 2006 14:05:40 +0000 Subject: [PATCH] magic-removal: Fixed #1651 -- 'startproject' and 'startapp' now copy permission bits. Thanks, pb git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2709 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/management.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/django/core/management.py b/django/core/management.py index 6b26d8b58a..31b61e2536 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -3,7 +3,7 @@ import django from django.core.exceptions import ImproperlyConfigured -import os, re, sys, textwrap +import os, re, shutil, sys, textwrap from optparse import OptionParser from django.utils import termcolors @@ -631,11 +631,14 @@ def _start_helper(app_or_project, name, directory, other_name=''): for f in files: if f.endswith('.pyc'): continue - fp_old = open(os.path.join(d, f), 'r') - fp_new = open(os.path.join(top_dir, relative_dir, f.replace('%s_name' % app_or_project, name)), 'w') + path_old = os.path.join(d, f) + path_new = os.path.join(top_dir, relative_dir, f.replace('%s_name' % app_or_project, name)) + fp_old = open(path_old, 'r') + fp_new = open(path_new, 'w') fp_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name).replace('{{ %s_name }}' % other, other_name)) fp_old.close() fp_new.close() + shutil.copymode(path_old, path_new) def startproject(project_name, directory): "Creates a Django project for the given project_name in the given directory."