Author: jmorliaguet
Date: Thu Dec  8 01:02:40 2005
New Revision: 1988

Modified:
   cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
   cpsskins/branches/jmo-perspectives/perspectives/perspective.xml
Log:

- fixed the xml export of settings



Modified: cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  
(original)
+++ cpsskins/branches/jmo-perspectives/engines/sitedesigner/browser.py  Thu Dec 
 8 01:02:40 2005
@@ -20,7 +20,6 @@
 import time
 
 from tarfile import TarFile, TarInfo
-from cStringIO import StringIO
 
 from zope.app.interface import queryType
 from zope.app.publisher.browser import BrowserView
@@ -30,18 +29,10 @@
     ISetting, IResourceType, IResource, IResourceManager,
     )
 
-setting_xml = """
-<configure
-    xmlns="http://namespaces.zope.org/cpsskins";>
-
-  <setting
-      name="%(setting_name)s"
-      type="%(resource_type)s"
-      resource="%(resource_name)s"
-      file="%(resource_filename)s"
-  />
-
-</configure>
+setting_xml = """<?xml version="1.0"?>
+<setting name="%(name)s" title="%(title)s">
+  %(resource)s
+</setting>
 """
 
 class SiteDesignerView(BrowserView):
@@ -86,40 +77,19 @@
         resource_type = queryType(resource, IResourceType)
 
         filename = name.replace(' ', '_')
-        archive_filename = '%s.tgz' % filename
-        setting_filename = '%s.zcml' % filename
-        resource_filename = '%s.xml' % filename
+        setting_filename = '%s.xml' % filename
 
         response = request.response
-        response.setHeader('content-type', 'application/x-gzip')
+        response.setHeader('content-type', 'text/xml')
         response.setHeader('Content-disposition',
-                           'attachment; filename=%s' % archive_filename)
-
-        # TODO to move to cpsskins.setup
-        archive_stream = StringIO()
-        file = TarFile.open(archive_filename, 'w:gz', archive_stream)
+                           'attachment; filename=%s' % setting_filename)
 
         # export the resource
         exporter = getMultiAdapter((resource, request), name='exporter')
-        text = exporter()
 
-        info = TarInfo(resource_filename)
-        info.size = len(text)
-        info.mtime = time.time()
-        file.addfile(info, StringIO(text))
-
-        # write the zcml
-        setting_zcml = setting_xml % {
-            'resource_type': resource_type.__identifier__,
-            'setting_name': name,
-            'resource_name': getattr(resource, 'name', None) or \
-                             resource.identifier,
-            'resource_filename': resource_filename,
+        return setting_xml % {
+            'name': name,
+            'title': setting.title,
+            'resource': exporter(),
             }
-        info = TarInfo(setting_filename)
-        info.size = len(setting_zcml)
-        info.mtime = time.time()
-        file.addfile(info, StringIO(setting_zcml))
 
-        file.close()
-        return archive_stream.getvalue()

Modified: cpsskins/branches/jmo-perspectives/perspectives/perspective.xml
==============================================================================
--- cpsskins/branches/jmo-perspectives/perspectives/perspective.xml     
(original)
+++ cpsskins/branches/jmo-perspectives/perspectives/perspective.xml     Thu Dec 
 8 01:02:40 2005
@@ -1,4 +1,3 @@
-<?xml version="1.0"?>
 <perspective xmlns:tal="http://xml.zope.org/namespaces/tal";
              tal:attributes="name context/name; title context/title"
 />
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to