Author: carljm Date: 2011-10-24 13:50:39 -0700 (Mon, 24 Oct 2011) New Revision: 17030
Modified: django/trunk/django/core/management/base.py django/trunk/django/core/management/commands/startapp.py Log: Fixed #17099 -- Removed an out-of-date warning and some unused code, now that startapp doesn't require creating app inside project. Thanks ptone for the report. Modified: django/trunk/django/core/management/base.py =================================================================== --- django/trunk/django/core/management/base.py 2011-10-23 15:19:09 UTC (rev 17029) +++ django/trunk/django/core/management/base.py 2011-10-24 20:50:39 UTC (rev 17030) @@ -357,7 +357,7 @@ """ raise NotImplementedError() -def copy_helper(style, app_or_project, name, directory, other_name=''): +def copy_helper(style, app_or_project, name, directory): """ Copies either a Django application layout template or a Django project layout template into the specified directory. @@ -367,11 +367,9 @@ # app_or_project -- The string 'app' or 'project'. # name -- The name of the application or project. # directory -- The directory to which the layout template should be copied. - # other_name -- When copying an application layout, this should be the name - # of the project. import re import shutil - other = {'project': 'app', 'app': 'project'}[app_or_project] + if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name. # Provide a smart error message, depending on the error. if not re.search(r'^[_a-zA-Z]', name): @@ -406,7 +404,7 @@ 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_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name)) fp_old.close() fp_new.close() try: Modified: django/trunk/django/core/management/commands/startapp.py =================================================================== --- django/trunk/django/core/management/commands/startapp.py 2011-10-23 15:19:09 UTC (rev 17029) +++ django/trunk/django/core/management/commands/startapp.py 2011-10-24 20:50:39 UTC (rev 17030) @@ -17,14 +17,6 @@ if directory is None: directory = os.getcwd() - # Determine the project_name by using the basename of directory, - # which should be the full path of the project directory (or the - # current directory if no directory was passed). - project_name = os.path.basename(directory) - if app_name == project_name: - raise CommandError("You cannot create an app with the same name" - " (%r) as your project." % app_name) - # Check that the app_name cannot be imported. try: import_module(app_name) @@ -33,15 +25,4 @@ else: raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as an app name. Please try another name." % app_name) - copy_helper(self.style, 'app', app_name, directory, project_name) - -class ProjectCommand(Command): - help = ("Creates a Django app directory structure for the given app name" - " in this project's directory.") - - def __init__(self, project_directory): - super(ProjectCommand, self).__init__() - self.project_directory = project_directory - - def handle_label(self, app_name, **options): - super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options) + copy_helper(self.style, 'app', app_name, directory) -- You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com. To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-updates?hl=en.