diff options
author | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-11-30 14:25:26 +0100 |
---|---|---|
committer | Sebastian Spaeth <Sebastian@SSpaeth.de> | 2012-11-30 14:25:26 +0100 |
commit | df1c497609fd47379d4a4bd36af4f3db2f722d3d (patch) | |
tree | 38837fb12d4b21a9b0799748559104f987550805 /mediagoblin/db/mixin.py | |
parent | 27886480abc83b52ce43b0c4637c6878700fbb0e (diff) | |
download | mediagoblin-df1c497609fd47379d4a4bd36af4f3db2f722d3d.tar.lz mediagoblin-df1c497609fd47379d4a4bd36af4f3db2f722d3d.tar.xz mediagoblin-df1c497609fd47379d4a4bd36af4f3db2f722d3d.zip |
Use mediagoblin import machinery
Rather than manually __importing__ the MEDIA_MANAGER, we should have
been using tools.common.import_component in the first place.
But even better to use the existing get_media_manager() function that
exists for exactly our purpose. Also improve documentation of what happens
in case of failure.
Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
Diffstat (limited to 'mediagoblin/db/mixin.py')
-rw-r--r-- | mediagoblin/db/mixin.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mediagoblin/db/mixin.py b/mediagoblin/db/mixin.py index e9fdfcb7..7b4bafce 100644 --- a/mediagoblin/db/mixin.py +++ b/mediagoblin/db/mixin.py @@ -29,6 +29,7 @@ real objects. from mediagoblin import mg_globals from mediagoblin.auth import lib as auth_lib +from mediagoblin.media_types import get_media_manager from mediagoblin.tools import common, licenses from mediagoblin.tools.text import cleaned_markdown_conversion from mediagoblin.tools.url import slugify @@ -122,11 +123,11 @@ class MediaEntryMixin(object): thumb_url = mg_globals.app.public_store.file_url( self.media_files[u'thumb']) else: - # no thumbnail in media available. Get the media's + # No thumbnail in media available. Get the media's # MEDIA_MANAGER for the fallback icon and return static URL - manager = __import__(self.media_type) - thumb_url = manager.MEDIA_MANAGER[u'default_thumb'] - thumb_url = mg_globals.app.staticdirector(thumb_url) # use static + # Raise FileTypeNotSupported in case no such manager is enabled + manager = get_media_manager(self.media_type) + thumb_url = mg_globals.app.staticdirector(manager[u'default_thumb']) return thumb_url def get_fail_exception(self): |