Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17030 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d89be53d95e1bc6827177d98d3c301e1f6c6fd9e 1 parent 965c5d7
Carl Meyer authored October 24, 2011
8  django/core/management/base.py
@@ -357,7 +357,7 @@ def handle_noargs(self, **options):
357 357
         """
358 358
         raise NotImplementedError()
359 359
 
360  
-def copy_helper(style, app_or_project, name, directory, other_name=''):
  360
+def copy_helper(style, app_or_project, name, directory):
361 361
     """
362 362
     Copies either a Django application layout template or a Django project
363 363
     layout template into the specified directory.
@@ -367,11 +367,9 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
367 367
     # app_or_project -- The string 'app' or 'project'.
368 368
     # name -- The name of the application or project.
369 369
     # directory -- The directory to which the layout template should be copied.
370  
-    # other_name -- When copying an application layout, this should be the name
371  
-    #               of the project.
372 370
     import re
373 371
     import shutil
374  
-    other = {'project': 'app', 'app': 'project'}[app_or_project]
  372
+
375 373
     if not re.search(r'^[_a-zA-Z]\w*$', name): # If it's not a valid directory name.
376 374
         # Provide a smart error message, depending on the error.
377 375
         if not re.search(r'^[_a-zA-Z]', name):
@@ -406,7 +404,7 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
406 404
             path_new = os.path.join(top_dir, relative_dir, f.replace('%s_name' % app_or_project, name))
407 405
             fp_old = open(path_old, 'r')
408 406
             fp_new = open(path_new, 'w')
409  
-            fp_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name).replace('{{ %s_name }}' % other, other_name))
  407
+            fp_new.write(fp_old.read().replace('{{ %s_name }}' % app_or_project, name))
410 408
             fp_old.close()
411 409
             fp_new.close()
412 410
             try:
21  django/core/management/commands/startapp.py
@@ -17,14 +17,6 @@ def handle_label(self, app_name, directory=None, **options):
17 17
         if directory is None:
18 18
             directory = os.getcwd()
19 19
 
20  
-        # Determine the project_name by using the basename of directory,
21  
-        # which should be the full path of the project directory (or the
22  
-        # current directory if no directory was passed).
23  
-        project_name = os.path.basename(directory)
24  
-        if app_name == project_name:
25  
-            raise CommandError("You cannot create an app with the same name"
26  
-                               " (%r) as your project." % app_name)
27  
-
28 20
         # Check that the app_name cannot be imported.
29 21
         try:
30 22
             import_module(app_name)
@@ -33,15 +25,4 @@ def handle_label(self, app_name, directory=None, **options):
33 25
         else:
34 26
             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)
35 27
 
36  
-        copy_helper(self.style, 'app', app_name, directory, project_name)
37  
-
38  
-class ProjectCommand(Command):
39  
-    help = ("Creates a Django app directory structure for the given app name"
40  
-            " in this project's directory.")
41  
-
42  
-    def __init__(self, project_directory):
43  
-        super(ProjectCommand, self).__init__()
44  
-        self.project_directory = project_directory
45  
-
46  
-    def handle_label(self, app_name, **options):
47  
-        super(ProjectCommand, self).handle_label(app_name, self.project_directory, **options)
  28
+        copy_helper(self.style, 'app', app_name, directory)

0 notes on commit d89be53

Please sign in to comment.
Something went wrong with that request. Please try again.