Django

Code

Ticket #6654 (closed: fixed)

Opened 9 months ago

Last modified 6 months ago

django-admin.py startproject/startapp commands fixes

Reported by: i_i Assigned to: i_i
Milestone: Component: django-admin.py
Version: SVN Keywords: startproject startapp command
Cc: ivan.illarionov@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

django-admin.py startproject command can create projects with names that conflict with existing installed Python modules. I fixed this. See attached patch. It won't allow users accidentally block existing python modules or create several projects with the same name in different places and therefore prevent potential hard-to-diagnose bugs.

Attachments

startproject.patch (1.3 kB) - added by i_i on 02/24/08 17:12:44.
startproject command fix
startproject-7320.patch (1.3 kB) - added by i_i on 03/31/08 06:42:11.
Updated to latest revision
startproject-startapp.patch (2.5 kB) - added by i_i on 03/31/08 07:56:40.
startapp included
startproject-startapp.2.patch (2.3 kB) - added by i_i on 03/31/08 11:40:50.
fixed startapp.py

Change History

02/24/08 17:12:44 changed by i_i

  • attachment startproject.patch added.

startproject command fix

03/31/08 06:42:11 changed by i_i

  • attachment startproject-7320.patch added.

Updated to latest revision

(follow-up: ↓ 2 ) 03/31/08 07:22:32 changed by ramiro

  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp.

(in reply to: ↑ 1 ; follow-up: ↓ 3 ) 03/31/08 07:33:03 changed by i_i

Replying to ramiro:

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp. Yes, that's why I updated it. All names in INVALID_PROJECT_NAMES will be detected by import.

(in reply to: ↑ 2 ) 03/31/08 07:33:58 changed by i_i

Replying to i_i:

Replying to ramiro:

This same problem was dealt at exactly that commit ([7320]) but in a slightly different way (it also checks importing a module with that name but additionally compares it against against the INVALID_PROJECT_NAMES list. Are you saying with your patch that the INVALID_PROJECT_NAMES test isn't necessary?. #6509 is similar but for startapp.

Yes, that's why I updated it. All names in INVALID_PROJECT_NAMES will be detected by import.

03/31/08 07:56:40 changed by i_i

  • attachment startproject-startapp.patch added.

startapp included

03/31/08 08:35:50 changed by i_i

Comments:

1. Names django, test and site will all be imported in the try/except/else clause and generate CommandError?. This makes INVALID_PROJECT_NAMES test unnecessary.

2. Ticket #6789 that was committed in 7320 is a duplicate of this ticket and deals with the same problem in a less efficient way.

3. The fix for #6509 is also added.

03/31/08 11:40:50 changed by i_i

  • attachment startproject-startapp.2.patch added.

fixed startapp.py

03/31/08 11:47:01 changed by i_i

  • owner changed from nobody to i_i.

03/31/08 11:48:05 changed by i_i

  • keywords changed from startproject command to startproject startapp command.
  • summary changed from django-admin.py startproject command enhancement/fix to django-admin.py startproject/startapp commands fixes.

06/14/08 02:01:14 changed by Simon Greenhill

  • stage changed from Unreviewed to Ready for checkin.

06/15/08 22:56:49 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [7652]) Fixed #6654 -- Slightly refactored the way 'startproject' and 'startapp' check for existing Python modules. Thanks, i_i


Add/Change #6654 (django-admin.py startproject/startapp commands fixes)




Change Properties
Action