36 | | continue |
37 | | |
38 | | # Step 3: import the app's admin file. If this has errors we want them |
39 | | # to bubble up. |
40 | | __import__("%s.admin" % app) |
| 34 | # The admin module may be raising an ImportError itself, so if |
| 35 | # this is the case, we want that error to bubble up. However, if |
| 36 | # this app simply does not provide an admin module, we want to |
| 37 | # silently continue to the next app. |
| 38 | # |
| 39 | # Checking to see if this app has an admin module requires one of |
| 40 | # two different approaches. If this app was imported through the |
| 41 | # use of a custom importer, we need to use that importer's |
| 42 | # find_module method, otherwise, we can just use imp.find_module. |
| 43 | # (imp does not have support for custom import hooks. For details, |
| 44 | # see the section titled "Integration with the 'imp' module" at |
| 45 | # http://www.python.org/dev/peps/pep-0302/) |
| 46 | # |
| 47 | # imp.find_module will raise an ImportError if it fails to find |
| 48 | # the specified module, but a custom importer will return None (as |
| 49 | # defined in PEP 302). |
| 50 | importer = sys.path_importer_cache.get(app_path[0], None) or imp |
| 51 | try: |
| 52 | if importer.find_module('admin', app_path) is not None: |
| 53 | # The admin module exists, so let the ImportError bubble up. |
| 54 | raise |
| 55 | except ImportError: |
| 56 | # The module failed to import and doesn't exist, so move on. |
| 57 | continue |