Author: jmorliaguet
Date: Sat Apr  8 15:20:20 2006
New Revision: 2787

Added:
   cpsskins/branches/jmo-perspectives/standard/io/storage.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/storage.zcml   (contents, 
props changed)
Modified:
   cpsskins/branches/jmo-perspectives/standard/io/configure.zcml
   cpsskins/branches/jmo-perspectives/ui/panels/io.pt
Log:

- added a storage exporter



Modified: cpsskins/branches/jmo-perspectives/standard/io/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/io/configure.zcml       
(original)
+++ cpsskins/branches/jmo-perspectives/standard/io/configure.zcml       Sat Apr 
 8 15:20:20 2006
@@ -9,4 +9,6 @@
 
   <include file="color.zcml" />
 
+  <include file="storage.zcml" />
+
 </configure>

Added: cpsskins/branches/jmo-perspectives/standard/io/storage.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/storage.py   Sat Apr  8 
15:20:20 2006
@@ -0,0 +1,71 @@
+############################################################################
+#
+# 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 xml.dom.minidom import parseString
+
+from zope.app import zapi
+from zope.component import adapts, getMultiAdapter
+from zope.interface import implements
+
+from cpsskins.elements.interfaces import IElement
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+
+XML = u"""<storage name="%(name)s">
+  %(content)s
+</storage>
+"""
+
+class Exporter(object):
+    """Export a storage.
+    """
+    implements(IDataExporter)
+
+    def __init__(self, context, request):
+        self.context = context
+        self.request = request
+
+    def __call__(self):
+        return u'<?xml version="1.0"?>\n' + self.toXML(self.context)
+
+    def toXML(self, storage=None):
+        request = self.request
+        xml = u''
+        for item in storage:
+            exporter = getMultiAdapter((storage[item], request), IDataExporter)
+            xml += exporter().replace('<?xml version="1.0"?>', '')
+
+        return XML % {
+            'name': zapi.name(storage),
+            'content': xml,
+        }
+
+class Importer(object):
+    """Import an element.
+    """
+    adapts(IElement)
+    implements(IDataImporter)
+
+    def __init__(self, context):
+        self.context = context
+
+    def load(self, xml=u''):
+        context = self.context
+        dom = parseString(xml)
+        print dom
+

Added: cpsskins/branches/jmo-perspectives/standard/io/storage.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/storage.zcml Sat Apr  8 
15:20:20 2006
@@ -0,0 +1,18 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope";
+    xmlns:browser="http://namespaces.zope.org/browser";>
+
+  <!-- XML export -->
+  <browser:view
+      provides="cpsskins.setup.interfaces.IDataExporter"
+      for="cpsskins.storage.interfaces.IStorage"
+      class=".storage.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".storage.Importer"
+  />
+
+</configure>

Modified: cpsskins/branches/jmo-perspectives/ui/panels/io.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/panels/io.pt  (original)
+++ cpsskins/branches/jmo-perspectives/ui/panels/io.pt  Sat Apr  8 15:20:20 2006
@@ -1,8 +1,14 @@
 
-  <div class="sections">
-    <img class="icon"
-         src="/++skin++cpsskins/@@/++resource++io-48.png" />
-    <span class="description">export, import themes and settings ...</span>
-    <br style="clear:both"/>
-  </div>
+<div class="sections">
+  <img class="icon"
+       src="/++skin++cpsskins/@@/++resource++io-48.png" />
+  <span class="description">export, import themes and settings ...</span>
+
+  <ul>
+    <li><a href="@@exportStorage?name=relations">Export relations</a></li>
+  </ul>
+
+  <br style="clear:both"/>
+
+</div>
 
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to