Author: jmorliaguet
Date: Mon Mar 27 22:52:06 2006
New Revision: 2739

Modified:
   cpsskins/branches/jmo-perspectives/io/README.txt
   cpsskins/branches/jmo-perspectives/io/style.py
   cpsskins/branches/jmo-perspectives/io/style.xml
Log:

- test update: XML export of styles



Modified: cpsskins/branches/jmo-perspectives/io/README.txt
==============================================================================
--- cpsskins/branches/jmo-perspectives/io/README.txt    (original)
+++ cpsskins/branches/jmo-perspectives/io/README.txt    Mon Mar 27 22:52:06 2006
@@ -13,8 +13,6 @@
 type names. Finally the resource's own identifier is used.
 
 
-    >>> from zope.app.testing import ztapi
-
 Classification of resources
 ===========================
 
@@ -43,6 +41,7 @@
 The element type of a given resource is obtained by querying the resource's
 IElementType.
 
+    >>> from zope.app.testing import ztapi
     >>> from zope.app.interface import queryType
 
     >>> from cpsskins.elements.interfaces import IElementType
@@ -159,3 +158,27 @@
     u'format-style-12345'
 
 
+Export of resources
+===================
+
+Resources can be exported using the IDataExporter adapter.
+
+    >>> from zope.publisher.browser import TestRequest
+    >>> from zope.component import getMultiAdapter
+
+    >>> from cpsskins.io.interfaces import IDataExporter, IDataImporter
+
+    >>> resource = Style()
+    >>> resource[u'div.body'] = {'color': u'red', 'border': u'none'}
+    >>> exporter = getMultiAdapter((resource, TestRequest()), IDataExporter)
+
+    >>> print exporter()
+    <?xml version="1.0"?>
+    <style uri="format-style-12345">
+      <selector name="div.body">
+        <property name="color" value="red"/>
+        <property name="border" value="none"/>
+      </selector>
+    </style>
+    <BLANKLINE>
+

Modified: cpsskins/branches/jmo-perspectives/io/style.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/io/style.py      (original)
+++ cpsskins/branches/jmo-perspectives/io/style.py      Mon Mar 27 22:52:06 2006
@@ -25,6 +25,7 @@
 from zope.interface import implements
 
 from cpsskins.ui.standard.formats.style import IStyle
+from cpsskins.elements.interfaces import IIdentifiable
 from cpsskins.io.interfaces import IDataExporter, IDataImporter
 
 class Exporter(object):
@@ -38,12 +39,15 @@
         return self.template()
 
     def getInfo(self):
-        info = []
+        selectors = []
         for k, v in self.context.items():
             properties = [{'name': name, 'value': value}
                          for name, value in v.items()]
-            info.append({'selector': k, 'properties': properties})
-        return info
+            selectors.append({'name': k, 'properties': properties})
+        return {
+            'uri': IIdentifiable(self.context).getURI(),
+            'selectors': selectors,
+        }
 
 class Importer(object):
     """This adapter makes it possible to import style resources.

Modified: cpsskins/branches/jmo-perspectives/io/style.xml
==============================================================================
--- cpsskins/branches/jmo-perspectives/io/style.xml     (original)
+++ cpsskins/branches/jmo-perspectives/io/style.xml     Mon Mar 27 22:52:06 2006
@@ -1,8 +1,10 @@
 <?xml version="1.0"?>
-<style xmlns:tal="http://xml.zope.org/namespaces/tal";>
-  <selector tal:repeat="info view/getInfo"
-            tal:attributes="name info/selector">
-    <property tal:repeat="prop info/properties"
+<style xmlns:tal="http://xml.zope.org/namespaces/tal";
+       tal:define="info view/getInfo"
+       tal:attributes="uri info/uri">
+  <selector tal:repeat="selector info/selectors"
+            tal:attributes="name selector/name">
+    <property tal:repeat="prop selector/properties"
               tal:attributes="name prop/name; value prop/value" />
   </selector>
 </style>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to