summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Meyer <carl@oddbird.net>2011-10-24 20:50:39 +0000
committerCarl Meyer <carl@oddbird.net>2011-10-24 20:50:39 +0000
commitd89be53d95e1bc6827177d98d3c301e1f6c6fd9e (patch)
tree1fbcdb90edc3b6420b75a0c0ed6c3a8f249a84e9
parent965c5d7cced0d2e09f5b0c3165c192ab4334331b (diff)
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
-rw-r--r--django/core/management/base.py8
-rw-r--r--django/core/management/commands/startapp.py21
2 files changed, 4 insertions, 25 deletions
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 6b9ce6e171..f1d8263550 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -357,7 +357,7 @@ class NoArgsCommand(BaseCommand):
"""
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 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
# 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 @@ def copy_helper(style, app_or_project, name, directory, other_name=''):
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:
diff --git a/django/core/management/commands/startapp.py b/django/core/management/commands/startapp.py
index 13d64834a6..2999a33ed4 100644
--- a/django/core/management/commands/startapp.py
+++ b/django/core/management/commands/startapp.py
@@ -17,14 +17,6 @@ class Command(LabelCommand):
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 @@ class Command(LabelCommand):
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)