Merge remote-tracking branch 'refs/remotes/elrond/sql/final'
[mediagoblin.git] / mediagoblin / staticdirect.py
index 5817588158f303724a14a31ce6cfedbcd71aa947..7477de68b8d62cbf9d43c8e5af6c736b5307316c 100644 (file)
@@ -1,5 +1,5 @@
 # GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 MediaGoblin contributors.  See AUTHORS.
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Affero General Public License as published by
 # You should have received a copy of the GNU Affero General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-import pkg_resources
-import urlparse
-
 ####################################
 # Staticdirect infrastructure.
 # Borrowed largely from cc.engine
 # by Chris Webber & Creative Commons
-# 
+#
 # This needs documentation!
 ####################################
 
 import pkg_resources
-import urlparse
+import logging
+
+_log = logging.getLogger(__name__)
+
 
 class StaticDirect(object):
     def __init__(self):
         self.cache = {}
 
     def __call__(self, filepath):
-        if self.cache.has_key(filepath):
+        if filepath in self.cache:
             return self.cache[filepath]
 
+        if not pkg_resources.resource_exists('mediagoblin',
+                'static' + filepath):
+            _log.info("StaticDirect resource %r not found locally",
+                filepath)
         static_direction = self.cache[filepath] = self.get(filepath)
         return static_direction
-        
 
     def get(self, filepath):
         # should be implemented by the individual staticdirector