Author: jmorliaguet
Date: Sat Apr  8 15:50:43 2006
New Revision: 2788

Added:
   cpsskins/branches/jmo-perspectives/standard/io/effect.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/effect.xml   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/effect.zcml   (contents, 
props changed)
   cpsskins/branches/jmo-perspectives/standard/io/layout.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/layout.xml   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/layout.zcml   (contents, 
props changed)
   cpsskins/branches/jmo-perspectives/standard/io/widget.py   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/widget.xml   (contents, props 
changed)
   cpsskins/branches/jmo-perspectives/standard/io/widget.zcml   (contents, 
props changed)
Modified:
   cpsskins/branches/jmo-perspectives/standard/io/configure.zcml
   cpsskins/branches/jmo-perspectives/standard/io/relation.py
   cpsskins/branches/jmo-perspectives/standard/io/style.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 'widget', 'layout' and 'effect' XML exporters

- added 'format', 'relation', 'portlet' storage XML 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 15:50:43 2006
@@ -1,6 +1,10 @@
 <configure
     xmlns="http://namespaces.zope.org/zope";>
 
+  <include file="effect.zcml" />
+
+  <include file="layout.zcml" />
+
   <include file="perspective.zcml" />
 
   <include file="relation.zcml" />
@@ -11,4 +15,6 @@
 
   <include file="storage.zcml" />
 
+  <include file="widget.zcml" />
+
 </configure>

Added: cpsskins/branches/jmo-perspectives/standard/io/effect.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/effect.py    Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# 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.component import adapts
+from zope.interface import implements
+
+from cpsskins.standard.formats.effect import IEffect
+from cpsskins.elements.interfaces import IIdentifiable
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+
+class Exporter(object):
+    """Export effects
+    """
+    implements(IDataExporter)
+
+    template = pagetemplate.ViewPageTemplateFile('effect.xml')
+
+    def __call__(self):
+        return self.template()
+
+    def getInfo(self):
+        attrs = 'type', 'format', 'width', 'height', 'keep_ratio'
+        context = self.context
+        properties = [{'name': name, 'value': getattr(context, name)}
+                      for name in attrs]
+        return {
+            'uri': IIdentifiable(self.context).getURI(),
+            'properties': properties,
+        }
+
+class Importer(object):
+    """Import effects
+    """
+    adapts(IEffect)
+    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/effect.xml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/effect.xml   Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<effect xmlns:tal="http://xml.zope.org/namespaces/tal";
+       tal:define="info view/getInfo"
+       tal:attributes="uri info/uri">
+  <property tal:repeat="prop info/properties"
+            tal:attributes="name prop/name; value prop/value" />
+</effect>

Added: cpsskins/branches/jmo-perspectives/standard/io/effect.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/effect.zcml  Sat Apr  8 
15:50:43 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.standard.formats.effect.IEffect"
+      class=".effect.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".effect.Importer"
+  />
+
+</configure>

Added: cpsskins/branches/jmo-perspectives/standard/io/layout.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/layout.py    Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,63 @@
+##############################################################################
+#
+# 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.component import adapts
+from zope.interface import implements
+
+from cpsskins.standard.formats.layout import ILayout
+from cpsskins.elements.interfaces import IIdentifiable
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+
+class Exporter(object):
+    """Export layouts
+    """
+    implements(IDataExporter)
+
+    template = pagetemplate.ViewPageTemplateFile('layout.xml')
+
+    def __call__(self):
+        return self.template()
+
+    def getInfo(self):
+        context = self.context
+        properties = [{'name': name, 'value': value}
+                      for name, value in context.items()]
+        return {
+            'uri': IIdentifiable(self.context).getURI(),
+            'properties': properties,
+        }
+
+class Importer(object):
+    """Import layouts
+    """
+    adapts(ILayout)
+    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/layout.xml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/layout.xml   Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<layout xmlns:tal="http://xml.zope.org/namespaces/tal";
+       tal:define="info view/getInfo"
+       tal:attributes="uri info/uri">
+  <property tal:repeat="prop info/properties"
+            tal:attributes="name prop/name; value prop/value" />
+</layout>

Added: cpsskins/branches/jmo-perspectives/standard/io/layout.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/layout.zcml  Sat Apr  8 
15:50:43 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.standard.formats.layout.ILayout"
+      class=".layout.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".layout.Importer"
+  />
+
+</configure>

Modified: cpsskins/branches/jmo-perspectives/standard/io/relation.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/io/relation.py  (original)
+++ cpsskins/branches/jmo-perspectives/standard/io/relation.py  Sat Apr  8 
15:50:43 2006
@@ -19,7 +19,7 @@
 
 from xml.dom.minidom import parseString
 
-from zope.app import zapi, pagetemplate
+from zope.app import pagetemplate
 from zope.component import adapts
 from zope.interface import implements
 

Modified: cpsskins/branches/jmo-perspectives/standard/io/style.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/io/style.py     (original)
+++ cpsskins/branches/jmo-perspectives/standard/io/style.py     Sat Apr  8 
15:50:43 2006
@@ -19,8 +19,7 @@
 
 from xml.dom.minidom import parseString
 
-from zope.app import zapi, pagetemplate
-from zope.app.publisher.browser import BrowserView
+from zope.app import pagetemplate
 from zope.component import adapts
 from zope.interface import implements
 

Added: cpsskins/branches/jmo-perspectives/standard/io/widget.py
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/widget.py    Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,64 @@
+##############################################################################
+#
+# 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.component import adapts
+from zope.interface import implements
+
+from cpsskins.standard.formats.widget import IWidget
+from cpsskins.elements.interfaces import IIdentifiable
+from cpsskins.setup.interfaces import IDataExporter, IDataImporter
+
+class Exporter(object):
+    """Export widgets
+    """
+    implements(IDataExporter)
+
+    template = pagetemplate.ViewPageTemplateFile('widget.xml')
+
+    def __call__(self):
+        return self.template()
+
+    def getInfo(self):
+        attrs = 'type',
+        context = self.context
+        properties = [{'name': name, 'value': getattr(context, name)}
+                      for name in attrs]
+        return {
+            'uri': IIdentifiable(self.context).getURI(),
+            'properties': properties,
+        }
+
+class Importer(object):
+    """Import widgets
+    """
+    adapts(IWidget)
+    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/widget.xml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/widget.xml   Sat Apr  8 
15:50:43 2006
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<widget xmlns:tal="http://xml.zope.org/namespaces/tal";
+       tal:define="info view/getInfo"
+       tal:attributes="uri info/uri">
+  <property tal:repeat="prop info/properties"
+            tal:attributes="name prop/name; value prop/value" />
+</widget>

Added: cpsskins/branches/jmo-perspectives/standard/io/widget.zcml
==============================================================================
--- (empty file)
+++ cpsskins/branches/jmo-perspectives/standard/io/widget.zcml  Sat Apr  8 
15:50:43 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.standard.formats.widget.IWidget"
+      class=".widget.Exporter"
+      permission="zope.ManageContent"
+  />
+
+  <!-- XML import -->
+  <adapter
+      factory=".widget.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:50:43 2006
@@ -6,6 +6,8 @@
 
   <ul>
     <li><a href="@@exportStorage?name=relations">Export relations</a></li>
+    <li><a href="@@exportStorage?name=portlets">Export portlets</a></li>
+    <li><a href="@@exportStorage?name=formats">Export formats</a></li>
   </ul>
 
   <br style="clear:both"/>

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 15:50:43 2006
@@ -57,6 +57,11 @@
         attribute="refreshSettings"
     />
 
+    <page
+        name="exportStorage"
+        attribute="exportStorage"
+    />
+
   </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 15:50:43 2006
@@ -27,6 +27,7 @@
 from cpsskins.setup.interfaces import ISetting, IGlobalSetting, IDataExporter
 from cpsskins.setup.interfaces import IResourceType, IResourceManager, 
IResource
 from cpsskins.setup.registration import reloadSetting, refreshSettings
+from cpsskins.utils import getThemeManager
 
 setting_xml = """<?xml version="1.0"?>
 <setting name="%(name)s" title="%(title)s">
@@ -36,6 +37,10 @@
 
 class SiteDesignerView(BrowserView):
 
+    ###################################################################
+    # Settings
+    ###################################################################
+
     def getSettingInfo(self):
         """Return information about registered resources categorized by type.
         """
@@ -113,3 +118,30 @@
         """Refresh all settings stored on the file-system
         """
         refreshSettings()
+
+    ###################################################################
+    # Storage
+    ###################################################################
+
+    def exportStorage(self, name=u''):
+        """Export the storage as an XML file.
+        """
+        context = self.context
+        request = self.request
+        if not name:
+            raise KeyError("Must specify a storage name.")
+
+        mgr = getThemeManager()
+        storage = mgr[name]
+
+        filename = name.replace(' ', '_')
+        storage_filename = '%s.xml' % filename
+
+        response = request.response
+        response.setHeader('content-type', 'text/xml')
+        response.setHeader('Content-disposition',
+                           'attachment; filename=%s' % storage_filename)
+
+        exporter = getMultiAdapter((storage, request), IDataExporter)
+        return exporter()
+
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to