On 4 Jan 2011, at 20:15, Nils Fredrik Gjerull wrote:
> 
> Hi, Django folks!
> 
> 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?

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
[email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" 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-developers?hl=en.

Reply via email to