Jason Giedymin avatar Jason Giedymin committed 1e94469

- Modified utils.py to import the names file set in settings.py.
- Proposal for 'GENERATED_MEDIA_MAP_FILE' to be obtained (getattr) 'from django.conf.settings'.
A large split Django project may have the need for generating unique map files per
site/settings file.

Comments (0)

Files changed (1)

mediagenerator/utils.py

 import re
 
 try:
-    from _generated_media_names import NAMES
+    MEDIA_MAP_MODULE = os.path.splitext(os.path.basename(GENERATED_MEDIA_MAP_FILE))[0]
+    NAMES = __import__(MEDIA_MAP_MODULE, ['NAMES']).NAMES
 except ImportError:
     NAMES = None
 
 
 def get_production_mapping():
     if NAMES is None:
-        raise ImportError('Could not import _generated_media_names. This '
+        raise ImportError('Could not import map file "%s". This '
                           'file is needed for production mode. Please '
-                          'run manage.py generatemedia to create it.')
+                          'run manage.py generatemedia to create it.' \
+                          % MEDIA_MAP_MODULE)
     return NAMES
 
 def get_media_mapping():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.