On Oct 23, 2008, at 16:53, Kurt wrote:

>
> Could always use the super hacky "check the ImportError message for
> the name of the admin module" to decide whether to reraise the error
> or not.

Please don't.

The solution lies within the fourth argument to __import__.

The statement
   from x.y import z
equates to
   z = __import__("x.y", {}, {}, ["z"]).z
(I think you can guess what " as q" changes.)

So, what we want the autodiscover to do is to run
   from <appname> import admin
which would be
   mod = __import__(appname, {}, {}, "admin")

And that should be enough, since the admin registering machinery  
should caretake the rest-- the module has been imported. Proof:
 >>> __import__("django.core", {}, {}, ["files"]).files
<module 'django.core.files' from '.../django/core/files/__init__.pyc'>
-- Restart CPython --
 >>> __import__("django.core", {}, {}, [""]).files
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'files'

Hope that made sense,
Ludvig

--~--~---------~--~----~------------~-------~--~----~
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