This is my first time posting on the Django developer list. Thanks for
an amazing framework.
The Distribute build system supports namespaced packages
(http://packages.python.org/distribute/setuptools.html#namespace-packages).
I have found namespaced packages to be of great help for my use case. A
project I am working on started out with some apps that were specific
for that project. Now I need to create a sub-site that uses only some of
the apps of the original project. I pulled out two of the apps and
created two separate packages for them. Because the apps had quite
common package names I did not want to occupy my namespace with them, so
I put them in a namespace package. This appeared to work correctly until
I tried to put a management command into one of them. The command were
not discovered. I traced this to the find_management_module function in
the django.core.management module.
I have found a way to discover all management packages without having to
import all the app modules. I tried to do it by importing, but the
manage.py script were running noticeably slower. I have also made a test
case.
The code is in:
https://github.com/nilsfr/django/blob/pht/django/core/management/__init__.py
https://github.com/nilsfr/django/blob/pht/django/utils/importlib.py
https://github.com/nilsfr/django/tree/pht/tests/regressiontests/admin_scripts
I do not intend to use this for including different apps with the same
name, in the same project. Only to avoid occupying the namespace with
common names, so I can use the same app name for different projects.
Any chance of getting this into core?
Regards
--
Nils Fredrik Gjerull
-----------------------------
"Ministry of Eternal Affairs"
Computer Department
( Not an official title :) )
A similar request was made in ticket #14087. I closed that ticket as
wontfix because allowing multiple applications with the same name is
fundamentally problematic; however, you have highlighted that that
this problem isn't tied to having two apps with the same name in a
project.
Even better, you've provided a test case that demonstrates the problem
within normal usage.
So - I'm happy to reopen this ticket, and use your github branch as an
RFC patch. The core team is able to pull from github, but If you could
upload a raw patch version to Trac, that would also be helpful.
Yours,
Russ Magee %-)
I have a similar problem but with using pkgutil.extend_path().
I have 2 packages set up a bit like this:
company/
common/
company/
apps/
news/
management/
commands/
each using the pkgutil.extend_path() trick. However only the first one on the path will be searched for management commands.
Hopefully Nils' patch will fix this situation too
--
David Reynolds
da...@reynoldsfamily.org.uk
I have uploaded at git diff file to that ticket.
> Even better, you've provided a test case that demonstrates the problem
> within normal usage.
>
> So - I'm happy to reopen this ticket, and use your github branch as an
> RFC patch. The core team is able to pull from github, but If you could
> upload a raw patch version to Trac, that would also be helpful.
That's great :)