]> git.parisson.com Git - telemeta.git/commitdiff
check upload tmp_dir existence
authorGuillaume Pellerin <yomguy@parisson.com>
Sun, 10 Nov 2013 08:58:48 +0000 (09:58 +0100)
committerGuillaume Pellerin <yomguy@parisson.com>
Sun, 10 Nov 2013 08:58:48 +0000 (09:58 +0100)
example/sandbox/settings.py
telemeta/backup/core.py
telemeta/views/collection.py

index 0a38030063433b590fea2e4860526349361dd159..fe913c795593bc646821032e558aa41809910c17 100644 (file)
@@ -161,3 +161,5 @@ LOGIN_REDIRECT_URL = reverse_lazy('telemeta-desk-lists')
 
 EMAIL_HOST = 'localhost'
 DEFAULT_FROM_EMAIL = 'webmaster@parisson.com'
+
+FILE_UPLOAD_TEMP_DIR = '/tmp'
\ No newline at end of file
index 9c1e1c083f3b30a66fe1b601d0ef2751c1e9f478..395d7909834be6f3dafbe2f2d47aa9a2d77c77a4 100644 (file)
@@ -56,14 +56,14 @@ class CollectionSerializer(object):
             if len(buffer) == 0:
                 break
             hash.update(buffer)
-        file.close()            
+        file.close()
         return hash.hexdigest()
 
     def __get_media_filename(self, item):
         return str(item.id) + ".wav"
 
     def store(self, dest_dir):
-        """Serialize and store the collection with related items and media 
+        """Serialize and store the collection with related items and media
         files into a subdirectory of the provided directory
         """
         coll_dir = dest_dir + "/" + str(self.collection.id)
@@ -89,7 +89,7 @@ class CollectionSerializer(object):
             md5_file.close()
 
     def get_xml(self):
-        """Return a string containing the XML representation of the collection 
+        """Return a string containing the XML representation of the collection
         and related items
         """
         impl = getDOMImplementation()
@@ -117,5 +117,5 @@ class CollectionSerializer(object):
         tree.free()
 
         return xml
-        
+
 
index c02b8e41a147ff97090e8066b10c78a616a2dae0..c40ccb12b862a1bfde5970a0147dd7d3a5fb2e77 100644 (file)
@@ -178,7 +178,10 @@ class CollectionPackageView(View):
         import json
 
         collection = self.get_object()
-        temp = tempfile.TemporaryFile(prefix=settings.FILE_UPLOAD_TEMP_DIR+os.sep)
+        tmp_dir = getattr(settings, "FILE_UPLOAD_TEMP_DIR")
+        if not tmp_dir:
+            tmp_dir = '/tmp'
+        temp = tempfile.TemporaryFile(prefix=tmp_dir+os.sep)
         archive = zipfile.ZipFile(temp, 'w', zipfile.ZIP_DEFLATED, allowZip64=True)
         serializer = CollectionSerializer(collection)
         archive.writestr('%s/%s%s' % (collection.code, collection.code, '.xml'),