Author: jmorliaguet
Date: Tue May  2 12:11:08 2006
New Revision: 3020

Added:
   cpsskins/branches/paris-sprint-2006/standard/io/layout.py   (contents, props 
changed)
Modified:
   cpsskins/branches/paris-sprint-2006/setup/io.py
   cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml
   cpsskins/branches/paris-sprint-2006/standard/io/style.py
Log:

- added a layout DOM adapter.

- fixed the style adapter



Modified: cpsskins/branches/paris-sprint-2006/setup/io.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/setup/io.py     (original)
+++ cpsskins/branches/paris-sprint-2006/setup/io.py     Tue May  2 12:11:08 2006
@@ -150,7 +150,6 @@
                 continue
 
             text = node.getAttribute(name)
-            print node.getAttribute(u'value')
 
             field_io = IFieldIO(field, None)
             if field_io is None:

Modified: cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml      
(original)
+++ cpsskins/branches/paris-sprint-2006/standard/io/configure.zcml      Tue May 
 2 12:11:08 2006
@@ -49,4 +49,12 @@
       provides="cpsskins.setup.interfaces.IDOMAdapter"
   />
 
+  <!-- layouts -->
+  <adapter
+      for="cpsskins.standard.formats.layout.ILayout *"
+      factory="cpsskins.standard.io.layout.DOMAdapter"
+      permission="zope.ManageContent"
+      provides="cpsskins.setup.interfaces.IDOMAdapter"
+  />
+
 </configure>

Added: cpsskins/branches/paris-sprint-2006/standard/io/layout.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/paris-sprint-2006/standard/io/layout.py   Tue May  2 
12:11:08 2006
@@ -0,0 +1,56 @@
+##############################################################################
+#
+# Copyright (c) 2005-2006 Nuxeo and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+__docformat__ = "reStructuredText"
+
+from zope.interface import implements
+
+from cpsskins.setup.interfaces import IDOMAdapter
+from cpsskins.setup.io import BaseDOMAdapter
+from cpsskins.relations.interfaces import IRelatable
+
+class DOMAdapter(BaseDOMAdapter):
+    """DOM adapter for layouts
+    """
+    implements(IDOMAdapter)
+
+    def save(self):
+        context = self.context
+        node = self.node
+
+        document = self.document
+
+        layout_el = document.createElement(u'layout')
+        layout_el.setAttribute(u'id', unicode(IRelatable(context)))
+
+        for name, value in context.items():
+            prop_el = document.createElement(u'property')
+            prop_el.setAttribute(u'name', name)
+            prop_el.setAttribute(u'value', value)
+            layout_el.appendChild(prop_el)
+
+        node.appendChild(layout_el)
+
+    def load(self):
+        context = self.context
+        node = self.node
+
+        for prop in node.getElementsByTagName(u'property'):
+            name = prop.getAttribute(u'name')
+            value = prop.getAttribute(u'value')
+            context[name] = value
+

Modified: cpsskins/branches/paris-sprint-2006/standard/io/style.py
==============================================================================
--- cpsskins/branches/paris-sprint-2006/standard/io/style.py    (original)
+++ cpsskins/branches/paris-sprint-2006/standard/io/style.py    Tue May  2 
12:11:08 2006
@@ -53,13 +53,12 @@
         context = self.context
         node = self.node
 
-        for style_el in node.getElementsByTagName('style'):
-            for sel in style_el.getElementsByTagName('selector'):
-                sel_name = sel.getAttribute('name')
-                style_props = {}
-                for prop in sel.getElementsByTagName('property'):
-                    name = prop.getAttribute('name')
-                    value = prop.getAttribute('value')
-                    style_props[name] = value
-                context[sel_name] = style_props
+        for sel in node.getElementsByTagName(u'selector'):
+            sel_name = sel.getAttribute(u'name')
+            style_props = {}
+            for prop in sel.getElementsByTagName(u'property'):
+                name = prop.getAttribute(u'name')
+                value = prop.getAttribute(u'value')
+                style_props[name] = value
+            context[sel_name] = style_props
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to