#14087: django.core.management.get_commands only sees commands in the last
package
of a namespace package
----------------------------+-----------------------------------------------
Reporter: KyleMac | Owner: nobody
Status: new | Milestone:
Component: Core framework | Version: 1.2
Keywords: | Stage: Unreviewed
Has_patch: 0 |
----------------------------+-----------------------------------------------
If using the namespace features of setuptools, then get_commands will only
see the commands in the last package. If you have something like the
following:
{{{
company.app1.management.commands.command1
company.app2.management.commands.command2
}}}
then Django will only spot command2. I don't know what the proper fix
would be, but I use the following to fill in the gaps:
{{{
def find_namespace_commands():
try:
from django.conf import settings
apps = settings.INSTALLED_APPS
except (AttributeError, EnvironmentError, ImportError):
apps = []
import imp
from django.core.management import _commands, find_commands
from django.utils.importlib import import_module
for app in apps:
try:
app_path = import_module(app).__path__
except AttributeError:
continue
try:
imp.find_module('management', app_path)
except ImportError:
continue
mod = import_module('%s.management' % app)
if hasattr(mod, '__path__'):
for cmd in find_commands(mod.__path__[0]):
if _commands is None:
_commands = {}
if cmd not in _commands:
_commands[cmd] = app
find_namespace_commands()
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/14087>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.