Ticket #8245: 8245.diff
File 8245.diff, 1.7 KB (added by , 16 years ago) |
---|
-
django/contrib/admin/__init__.py
2 2 from django.contrib.admin.options import StackedInline, TabularInline 3 3 from django.contrib.admin.sites import AdminSite, site 4 4 5 LOADING_FLAG = '_admin_autodiscover_loading' 6 5 7 def autodiscover(): 6 8 """ 7 Auto-discover INSTALLED_APPS admin.py modules and fail silently when 9 Auto-discover INSTALLED_APPS admin.py modules and fail silently when 8 10 not present. This forces an import on them to register any admin bits they 9 11 may want. 10 12 """ … … 21 23 # should) bubble up, but a missing __path__ (which is legal, but weird) 22 24 # fails silently -- apps that do weird things with __path__ might 23 25 # need to roll their own admin registration. 26 app_mod = __import__(app, {}, {}, [app.split('.')[-1]]) 27 # Bail out if this app didn't finish loading from a previous call so 28 # that we avoid masking the real exception with an AlreadyRegistered 29 # exception. 30 if getattr(app_mod, LOADING_FLAG, False): 31 continue 32 # Set a flag to designate that this app is loading. 33 setattr(app_mod, LOADING_FLAG, True) 24 34 try: 25 app_path = __import__(app, {}, {}, [app.split('.')[-1]]).__path__35 app_path = app_mod.__path__ 26 36 except AttributeError: 27 37 continue 28 38 … … 38 48 # Step 3: import the app's admin file. If this has errors we want them 39 49 # to bubble up. 40 50 __import__("%s.admin" % app) 51 # Import was successful, remove loading flag. 52 delattr(app_mod, LOADING_FLAG)