Changeset 7652
- Timestamp:
- 06/15/08 22:56:48 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management/commands/startapp.py
r7294 r7652 4 4 5 5 class Command(LabelCommand): 6 help = ("Creates a Django app directory structure for the given app name" 7 " in the current directory.") 6 help = "Creates a Django app directory structure for the given app name in the current directory." 8 7 args = "[appname]" 9 8 label = 'application name' … … 17 16 if directory is None: 18 17 directory = os.getcwd() 18 19 19 # Determine the project_name by using the basename of directory, 20 20 # which should be the full path of the project directory (or the … … 24 24 raise CommandError("You cannot create an app with the same name" 25 25 " (%r) as your project." % app_name) 26 27 # Check that the app_name cannot be imported. 28 try: 29 __import__(app_name) 30 except ImportError: 31 pass 32 else: 33 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) 34 26 35 copy_helper(self.style, 'app', app_name, directory, project_name) 27 36 django/trunk/django/core/management/commands/startproject.py
r7320 r7652 3 3 import re 4 4 from random import choice 5 6 INVALID_PROJECT_NAMES = ('django', 'site', 'test')7 5 8 6 class Command(LabelCommand): … … 21 19 directory = os.getcwd() 22 20 21 # Check that the project_name cannot be imported. 23 22 try: 24 proj_name = __import__(project_name) 25 if proj_name: 26 raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) 23 __import__(project_name) 27 24 except ImportError: 28 if project_name in INVALID_PROJECT_NAMES: 29 raise CommandError("%r contains an invalid project name. Please try another name." % project_name) 25 pass 26 else: 27 raise CommandError("%r conflicts with the name of an existing Python module and cannot be used as a project name. Please try another name." % project_name) 30 28 31 29 copy_helper(self.style, 'project', project_name, directory)
