Click on annotation in the list to scroll to it in visual editor
[redakcja.git] / apps / dvcs / storage.py
1 from zlib import compress, decompress
2
3 from django.core.files.base import ContentFile, File
4 from django.core.files.storage import FileSystemStorage
5
6
7 class GzipFileSystemStorage(FileSystemStorage):
8     def _open(self, name, mode='rb'):
9         """TODO: This is good for reading; what about writing?"""
10         f = open(self.path(name), 'rb')
11         text = f.read()
12         f.close()
13         return ContentFile(decompress(text))
14
15     def _save(self, name, content):
16         content = ContentFile(compress(content.read()))
17
18         return super(GzipFileSystemStorage, self)._save(name, content)