v0.6.2 : enhance libadvene export V00.06.02
authorcavaliet
Thu, 02 Oct 2014 10:37:44 +0200
changeset 142 34ad53eecb18
parent 141 9ea9abf462fe
child 143 1327586de866
v0.6.2 : enhance libadvene export
src/spel/__init__.py
src/spel/views.py
--- a/src/spel/__init__.py	Wed Oct 01 17:15:49 2014 +0200
+++ b/src/spel/__init__.py	Thu Oct 02 10:37:44 2014 +0200
@@ -1,4 +1,4 @@
-VERSION = (0, 6, 1, "final", 0)
+VERSION = (0, 6, 2, "final", 0)
 
 VERSION_STR = unicode(".".join(map(lambda i:"%02d" % (i,), VERSION[:2])))
 
--- a/src/spel/views.py	Wed Oct 01 17:15:49 2014 +0200
+++ b/src/spel/views.py	Thu Oct 02 10:37:44 2014 +0200
@@ -502,17 +502,18 @@
             project = get_object_or_404(Project, ldt_id=id)
             ps = ProjectJsonSerializer(project)
             project_dict = ps.serialize_to_cinelab()
-            p = Package("http://spectacleenligne.fr", create=True)
+            p = Package("http://spectacleenlignes.fr" + request.path, create=True)
             Parser.parse_into(project_dict, p)
-            outfile = "/tmp/" + unicode(uuid.uuid1())
-            filedata = ""
-            if format == "rdf":
-                serialize_to_rdf(p, outfile)
-            elif format == "ttl":
-                serialize_to_ttl(p, outfile)
-            with open(outfile, "r") as myfile:
-                filedata = myfile.read()
-            return HttpResponse(filedata, content_type="text/plain")
+            
+            if format=="rdf":
+                content_type = "application/rdf+xml"
+                serialize_method= serialize_to_rdf
+            elif format=="ttl":
+                content_type = "text/turtle"
+                serialize_method= serialize_to_ttl
+            resp = HttpResponse(content_type=content_type)
+            serialize_method(p, resp)
+            return resp
         return project_json_id(request, id)
 
     
\ No newline at end of file