Browse files

document cloud files backend, rename it, and add supports_gzip method…

… to client
  • Loading branch information...
1 parent 539e4aa commit 87befd0d8efc452fe392e0eee03bc2712e58784c @jcarbaugh jcarbaugh committed Jan 10, 2011
View
3 AUTHORS
@@ -5,4 +5,5 @@ The following individuals have contributed to this project:
* James Turk
* Greg Taylor <gtaylor@duointeractive.com>
* Peter Sanchez
-* Jonathan Drosdeck
+* Jonathan Drosdeck
+* Rich Leland
View
41 README.rst
@@ -25,13 +25,14 @@ Requirements
* django >= 1.0
* boto >= 1.8d
* slimmer == 0.1.30 (optional)
+* python-cloudfiles == 1.7.5 (optional, for Rackspace Cloud Files backend)
----------------------------
Upgrading from mediasync 1.x
----------------------------
-1. Update your mediasync settings as described in the next section.
-1. Run *./manage.py syncmedia --force* to force updates of all files:
+#. Update your mediasync settings as described in the next section.
+#. Run *./manage.py syncmedia --force* to force updates of all files:
* gzip instead of deflate compression
* sync both compressed and original versions of files
#. add "django.core.context_processors.request" to TEMPLATE_CONTEXT_PROCESSORS
@@ -280,6 +281,33 @@ time-based cache buster value. Each worker/thread will probably have a slightly
different value for datetime.now(), which means your users will find themselves
having cache misses randomly from page to page.
+Rackspace Cloud Files
+---------------------
+
+::
+
+ MEDIASYNC['BACKEND'] = 'mediasync.backends.cloudfiles'
+
+Settings
+~~~~~~~~
+
+The following settings are required in the mediasync settings dict::
+
+ MEDIASYNC = {
+ 'CLOUDFILES_CONTAINER': 'container_name',
+ 'CLOUDFILES_USERNAME': 'cf_username',
+ 'CLOUDFILES_API_KEY': 'cf_apikey',
+ }
+
+Tips
+~~~~
+
+The Cloud Files backend lacks support for the following features:
+
+* setting HTTP Expires header
+* setting HTTP Cache-Control header
+* content compression (gzip)
+
Custom backends
---------------
@@ -304,6 +332,12 @@ put is responsible for pushing a file to the backend storage.
the file should be written
* force - if True, write file to remote storage even if it already exists
+If the client supports gzipped content, you will need to override supports_gzip
+to return True::
+
+ def supports_gzip(self):
+ return True
+
File Processors
===============
@@ -528,6 +562,7 @@ Change Log
2.0.0
=====
+* updated Rackspace Cloud Files backend
* use gzip instead of deflate for compression (better browser support)
* smart gzip client support detection
* add pluggable backends
@@ -543,7 +578,7 @@ Change Log
* add many more tests
* deprecate CSS_PATH and JS_PATH
-Thanks to Greg Taylor, Peter Sanchez, and Jonathan Drosdeck for their contributions to this release.
+Thanks to Greg Taylor, Peter Sanchez, Jonathan Drosdeck, and Rich Leland for their contributions to this release.
1.0.1
=====
View
3 mediasync/backends/__init__.py
@@ -40,6 +40,9 @@ def __init__(self, *args, **kwargs):
if callable(proc):
self.processors.append(proc)
+
+ def supports_gzip(self):
+ return False
def get_local_media_url(self):
"""
View
0 mediasync/backends/rackspace_cloudfiles.py → mediasync/backends/cloudfiles.py
File renamed without changes.
View
3 mediasync/backends/s3.py
@@ -19,6 +19,9 @@ def __init__(self, *args, **kwargs):
assert self.aws_bucket
+ def supports_gzip(self):
+ return True
+
def get_connection(self):
return self._conn
View
2 mediasync/templatetags/media.py
@@ -39,7 +39,7 @@ def supports_gzip(self, context):
to the gzipped version of files that are allowed to be compressed.
Clients without gzip support will be served the original media.
"""
- if 'request' in context:
+ if 'request' in context and client.supports_gzip():
enc = context['request'].META.get('HTTP_ACCEPT_ENCODING', '')
return 'gzip' in enc and msettings['SERVE_REMOTE']
return False
View
3 requirements.txt
@@ -1,2 +1,3 @@
boto>=1.8d,<2.0b1
-slimmer==0.1.30
+slimmer==0.1.30
+python-cloudfiles==1.7.5

0 comments on commit 87befd0

Please sign in to comment.