Author: jmorliaguet
Date: Sat Apr  8 17:22:03 2006
New Revision: 2791

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

- added theme / page exporters



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 17:22:03 2006
@@ -11,8 +11,12 @@
 
   <include file="effect.zcml" />
 
+  <include file="element.zcml" />
+
   <include file="layout.zcml" />
 
+  <include file="page.zcml" />
+
   <include file="perspective.zcml" />
 
   <include file="relation.zcml" />
@@ -23,6 +27,8 @@
 
   <include file="storage.zcml" />
 
+  <include file="theme.zcml" />
+
   <include file="widget.zcml" />
 
 </configure>

Added: cpsskins/branches/jmo-perspectives/standard/io/page.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/page.py      Sat Apr  8 
17:22:03 2006
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# 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 pagetemplate
+from zope.app.interface import queryType
+from zope.component import adapts, getMultiAdapter
+from zope.interface import implements
+
+from cpsskins.elements.interfaces import IIdentifiable
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+from cpsskins.elements.interfaces import IThemePage
+
+class Exporter(object):
+    """Export pages
+    """
+    implements(IDataExporter)
+
+    template = pagetemplate.ViewPageTemplateFile('page.xml')
+
+    def __call__(self):
+        return self.template()
+
+    def getInfo(self):
+        context = self.context
+        request = self.request
+
+        xml = u''
+        for node in context:
+            exporter = getMultiAdapter((context[node], request), IDataExporter)
+            xml = exporter().replace('<?xml version="1.0"?>', '')
+
+        return {
+            'uri': IIdentifiable(context).getURI(),
+            'content': xml,
+            }
+
+
+class Importer(object):
+    """Import pages
+    """
+    adapts(IThemePage)
+    implements(IDataImporter)
+
+    def __init__(self, context):
+        self.context = context
+
+    def load(self, xml=u''):
+        context = self.context
+        dom = parseString(xml)
+        # TODO
+        print dom
+

Added: cpsskins/branches/jmo-perspectives/standard/io/page.xml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/page.xml     Sat Apr  8 
17:22:03 2006
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<page xmlns:tal="http://xml.zope.org/namespaces/tal";
+      tal:define="info view/getInfo"
+      tal:attributes="uri info/uri"
+      tal:content="structure info/content" />

Added: cpsskins/branches/jmo-perspectives/standard/io/page.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/page.zcml    Sat Apr  8 
17:22:03 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.elements.interfaces.IThemePage"
+      class=".page.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".page.Importer"
+  />
+
+</configure>

Modified: cpsskins/branches/jmo-perspectives/standard/io/storage.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/io/storage.py   (original)
+++ cpsskins/branches/jmo-perspectives/standard/io/storage.py   Sat Apr  8 
17:22:03 2006
@@ -23,7 +23,7 @@
 from zope.component import adapts, getMultiAdapter
 from zope.interface import implements
 
-from cpsskins.elements.interfaces import IElement
+from cpsskins.storage.interfaces import IStorage
 from cpsskins.setup.interfaces import IDataExporter, IDataImporter
 
 XML = u"""<storage name="%(name)s">
@@ -58,7 +58,7 @@
 class Importer(object):
     """Import an element.
     """
-    adapts(IElement)
+    adapts(IStorage)
     implements(IDataImporter)
 
     def __init__(self, context):

Added: cpsskins/branches/jmo-perspectives/standard/io/theme.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/theme.py     Sat Apr  8 
17:22:03 2006
@@ -0,0 +1,70 @@
+##############################################################################
+#
+# 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 pagetemplate
+from zope.app.interface import queryType
+from zope.component import adapts, getMultiAdapter
+from zope.interface import implements
+
+from cpsskins.elements.interfaces import IIdentifiable
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+from cpsskins.elements.interfaces import ITheme
+
+class Exporter(object):
+    """Export themes
+    """
+    implements(IDataExporter)
+
+    template = pagetemplate.ViewPageTemplateFile('theme.xml')
+
+    def __call__(self):
+        return self.template()
+
+    def getInfo(self):
+        context = self.context
+        request = self.request
+
+        xml = u''
+        for page in context.getPages():
+            exporter = getMultiAdapter((page, request), IDataExporter)
+            xml = exporter().replace('<?xml version="1.0"?>', '')
+
+        return {
+            'uri': IIdentifiable(context).getURI(),
+            'content': xml,
+            }
+
+
+class Importer(object):
+    """Import themes
+    """
+    adapts(ITheme)
+    implements(IDataImporter)
+
+    def __init__(self, context):
+        self.context = context
+
+    def load(self, xml=u''):
+        context = self.context
+        dom = parseString(xml)
+        # TODO
+        print dom
+

Added: cpsskins/branches/jmo-perspectives/standard/io/theme.xml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/theme.xml    Sat Apr  8 
17:22:03 2006
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<theme xmlns:tal="http://xml.zope.org/namespaces/tal";
+       tal:define="info view/getInfo"
+       tal:attributes="uri info/uri"
+       tal:content="structure info/content" />

Added: cpsskins/branches/jmo-perspectives/standard/io/theme.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/theme.zcml   Sat Apr  8 
17:22:03 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.elements.interfaces.ITheme"
+      class=".theme.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".theme.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 17:22:03 2006
@@ -5,6 +5,7 @@
   <span class="description">export, import themes and settings ...</span>
 
   <ul>
+    <li><a href="@@exportThemes">Export themes</a></li>
     <li><a href="@@exportSettings">Export settings</a></li>
     <li><a href="@@exportStorage?name=relations">Export relations</a></li>
     <li><a href="@@exportStorage?name=portlets">Export portlets</a></li>

Modified: 
cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml    
(original)
+++ cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/configure.zcml    
Sat Apr  8 17:22:03 2006
@@ -67,6 +67,11 @@
         attribute="exportStorage"
     />
 
+    <page
+        name="exportThemes"
+        attribute="exportThemes"
+    />
+
   </pages>
 
 </configure>

Modified: cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py  
(original)
+++ cpsskins/branches/jmo-perspectives/ui/screens/sitemanager/views.py  Sat Apr 
 8 17:22:03 2006
@@ -35,6 +35,13 @@
 </settings>
 """
 
+themes_xml = """<?xml version="1.0"?>
+<themes>
+  %(content)s
+</themes>
+"""
+
+
 class SiteDesignerView(BrowserView):
 
     ###################################################################
@@ -157,3 +164,26 @@
         exporter = getMultiAdapter((storage, request), IDataExporter)
         return exporter()
 
+    ###################################################################
+    # Themes
+    ###################################################################
+
+    def exportThemes(self):
+        """Export the themes
+        """
+        context = self.context
+        request = self.request
+
+        themes_filename = u'themes.xml'
+
+        response = request.response
+        response.setHeader('content-type', 'text/xml')
+        response.setHeader('Content-disposition',
+                           'attachment; filename=%s' % themes_filename)
+
+        xml = u''
+        for theme in getThemeManager().getThemes():
+            exporter = getMultiAdapter((theme, request), IDataExporter)
+            xml += exporter().replace('<?xml version="1.0"?>', '')
+
+        return themes_xml % {'content': xml}
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to