Hi all,
   I've opened a ticket on this matter (http://code.djangoproject.com/
ticket/9427) but the gist of it is this:

I have a django application that is packaged as an egg.  Inside this
package are many files which include an admin.py.  It would appear
that the rest of django finds the files inside (models.py for one)
because syncdb makes the tables and so forth.  However, the admin
application does not show anything for this application.  When the
application exists as a normal folder-style package, all is well.

As you can see in the ticket, I dug around contrib/admin/__init__.py
and debugged what it was doing there.  What it looks like is happening
is that imp.find_module() cannot find any file inside eggs.  Calling a
regular __import__ on the admin file inside that app works fine
though.

So what to do here? As I can see it, autodiscover does two things:
finds out the paths to where applications live and then imports their
admin.py if it exists.  Since we (apparently) cannot reliably
determine if an admin.py exists inside an application under all
circumstances using imp.find_module, we could just try to import the
admin.py and raise an error if it doesn't exist.  I think the larger
issue here is in imp and Alex agrees that its probably an upstream
issue but:

#1.  This egg packaged app worked everywhere else in Django as far as
I can tell
#2.  If this is indeed a problem in a major version of Python (2.5),
shouldn't we work around the issue as long as it keeps backwards
compatibility?

But what if there are errors inside the admin.py? We need to bubble
those up.

So after talking with Alex Gaynor and Brian Roser in #django-dev I
have attached a patch that essentially attempts to import the admin.py
in the application.  If that fails, it checks to see if that file
exists.  If it exists, we throw an exception because something is
obviously wrong.  If the import failed and the file doesn't exist,
then we just move on.

I'm throwing this out there just to get a wider eye on the patch just
in case there are any edge cases that these changes might affect.

Again the ticket is http://code.djangoproject.com/ticket/9427

Thanks!

--
Clint Ecker -- http://blog.clintecker.com
c: 312.863.9323
---
twitter: clint
skype: clintology
AIM: clintecker
Gtalk: [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 django-developers@googlegroups.com
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