Chris Beaven avatar Chris Beaven committed c2b7dae

Use a much more efficient way of getting file URLs for the CloudFilesStorage backend (by retrieving and caching the container's public_uri rather than getting the public uri for each and every object).

Comments (0)

Files changed (1)


         return self._container
-    def _set_container(self, value):
+    def _set_container(self, container):
         Set the container, making it publicly available (on Limelight CDN) if
         it is not already.
-        if not value.is_public():
-            value.make_public()
-        self._container = value
+        if not container.is_public():
+            container.make_public()
+        if hasattr(self, '_container_public_uri'):
+            delattr(self, '_container_public_uri')
+        self._container = container
     container = property(_get_container, _set_container)
+    def _get_container_url(self):
+        if not hasattr(self, '_container_public_uri'):
+            self._container_public_uri = self.container.public_uri()
+        return self._container_public_uri
+    container_url = property(_get_container_url)
     def _get_cloud_obj(self, name):
         Helper function to get retrieve the requested Cloud Files Object.
         Returns an absolute URL where the file's contents can be accessed
         directly by a web browser.
-        return self._get_cloud_obj(name).public_uri()
+        return '%s/%s' % (self.container_url, name)
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
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.