Author: jmorliaguet
Date: Sat Oct 29 13:05:28 2005
New Revision: 28796

Added:
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/authoring.py   
(contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/jsonrpc.py   
(contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/__init__.py   
(contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml   
(contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/edit.pt
      - copied unchanged from r28683, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/edit_control.pt
      - copied unchanged from r28683, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_control.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
      - copied unchanged from r28685, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_menu.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/edit_panel.pt
      - copied unchanged from r28683, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_panel.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/editing.css
      - copied unchanged from r28685, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/editing.css
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/editing.py   
(contents, props changed)
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/
      - copied from r28683, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/__init__.py
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/__init__.py
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/cell_edit_layout.pt
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/cell_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/configure.zcml
      - copied, changed from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/content/
      - copied from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/content/
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/layout.py
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/layout.py
   z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/page/
      - copied from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/page/
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/pageblock_edit_layout.pt
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/pageblock_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/theme_edit_layout.pt
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/theme_edit_layout.pt
   
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/themepage_edit_layout.pt
      - copied unchanged from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/themepage_edit_layout.pt
Removed:
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_control.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_menu.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/edit_panel.pt
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/editing.css
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/
Modified:
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/browser/configure.zcml
Log:
- some cleanup:

   authoring.py split up into:

    - authoring/authoring.py

    - authoring/jsonrpc.py

    - editing/editing.py



Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py      
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/__init__.py      
Sat Oct 29 13:05:28 2005
@@ -1,288 +1 @@
-##############################################################################
-#
-# Copyright (c) 2005 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.app import zapi
-from zope.app.container.browser.contents import Contents
-from zope.app.event.objectevent import ObjectCreatedEvent
-from zope.app.location.traversing import LocationPhysicallyLocatable
-from zope.app.publisher.browser import BrowserView
-from zope.app.session.interfaces import ISession
-from zope.app.traversing.api import getParent
-from zope.app.zapi import queryMultiAdapter, getMultiAdapter
-from zope.component import adapts
-from zope.component.interfaces import IFactory
-from zope.event import notify
-from zope.interface import implements
-from zope.security.proxy import removeSecurityProxy
-
-from jsonserver.interfaces import IJSONRPCPublisher
-
-from interfaces import IAuthoring, IEditing
-from cpsskins.elements.interfaces import IElement
-from cpsskins.elements.interfaces import IPresentable, IDisplayable, 
IFormattable
-from cpsskins.browser.elements.interfaces import INodeAdding, INodeRemoving
-from cpsskins.browser.elements.interfaces import INodeMoving, INodeOrdering
-from cpsskins.browser.elements.interfaces import INodeDuplicating
-from cpsskins.browser.rendering.interfaces import IViewer
-from cpsskins.thememanager import getThemeManager
-
-class Authoring(BrowserView):
-    adapts(IElement)
-    implements(IAuthoring)
-
-    def _redirect(self):
-        request = self.request
-        target = request.get('HTTP_REFERER', '.')
-        request.response.redirect(target)
-
-    def draw(self, **kw):
-        """Draws a the canvas element in edit mode
-        """
-        viewer = getMultiAdapter((self.context, self.request), IViewer)
-        return viewer(**kw)
-
-    def getCanvasMode(self):
-        """Get the canvas view mode
-        """
-        request = self.request
-        pkg_id = 'cpsskins'
-        session = ISession(request)[pkg_id]
-        try:
-            mode = session['canvas_mode']
-        except KeyError:
-            mode = None
-        return mode
-
-    def setCanvasMode(self, mode=None):
-        """Set the canvas view mode
-        """
-        pkg_id = 'cpsskins'
-        session = ISession(self.request)[pkg_id]
-        if mode is not None:
-            session['canvas_mode'] = mode
-        self._redirect()
-
-    def setPerspective(self, perspective=''):
-        """Set the perspective
-        """
-        pkg_id = 'cpsskins'
-        session = ISession(self.request)[pkg_id]
-
-        if not perspective:
-            del session['perspective']
-        else:
-            tmutil = getThemeManager()
-            theme = tmutil.getEffectiveTheme(self.context)
-            perspective = theme.getPerspectiveById(perspective)
-
-            # remove the security proxy before storing the object in the 
session
-            perspective = removeSecurityProxy(perspective)
-            session['perspective'] = perspective
-        self._redirect()
-
-    def clonePresentation(self, perspective=None):
-        """Clone a view in a given perspective by:
-
-        - assigning a new display to it
-
-        - by associating the original display's formats to the new display
-
-        """
-        tmutil = getThemeManager()
-        theme = tmutil.getEffectiveTheme(self.context)
-        perspective = theme.getPerspectiveById(perspective)
-        display = IDisplayable(self.context).getDisplay(perspective)
-        if display is None:
-            IPresentable(self.context).clonePresentation(perspective)
-        self._redirect()
-
-    def addPresentation(self, perspective=None):
-        tmutil = getThemeManager()
-        theme = tmutil.getEffectiveTheme(self.context)
-        perspective = theme.getPerspectiveById(perspective)
-        IPresentable(self.context).addPresentation(perspective)
-        self._redirect()
-
-    def removePresentation(self, perspective=None):
-        tmutil = getThemeManager()
-        theme = tmutil.getEffectiveTheme(self.context)
-        perspective = theme.getPerspectiveById(perspective)
-        IPresentable(self.context).removePresentation(perspective)
-        self._redirect()
-
-    def customizeFormat(self, name='', perspective=None):
-        tmutil = getThemeManager()
-        theme = tmutil.getEffectiveTheme(self.context)
-        perspective = theme.getPerspectiveById(perspective)
-        IPresentable(self.context).customizeFormat(name, perspective)
-        self._redirect()
-
-    def uncustomizeFormat(self, name='', perspective=None):
-        tmutil = getThemeManager()
-        theme = tmutil.getEffectiveTheme(self.context)
-        perspective = theme.getPerspectiveById(perspective)
-        IPresentable(self.context).uncustomizeFormat(name, perspective)
-        self._redirect()
-
-class Editing(BrowserView):
-
-    adapts(IElement)
-    implements(IEditing)
-
-    def getId(self):
-        """Return the element's id
-        """
-        return self.context.identifier
-
-    def getPath(self):
-        """Return the element's path
-        """
-        return LocationPhysicallyLocatable(self.context).getPath()
-
-    def getParent(self):
-        """Return the element's path
-        """
-        return getParent(self.context)
-
-    def getIcon(self):
-        """Return the element's icon path
-        """
-        icon_url = ''
-        icon = queryMultiAdapter((self.context, self.request), name='zmi_icon')
-        if icon:
-            icon_url = icon.url()
-        return icon_url
-
-
-class Methods(object):
-    """JSON-RPC methods.
-    """
-    implements(IJSONRPCPublisher)
-
-    def __init__(self, context, request):
-        request.form = {}
-        self.context = context
-        self.request = request
-
-    def _getElementById(self, id):
-        """Return an element by id.
-        """
-        tmutil = getThemeManager()
-        return tmutil.getElementById(id)
-
-    def renderElement(self, id, engine='default', canvas_mode=''):
-        """Render the element and return the markup
-        """
-        element = self._getElementById(id)
-        request = self.request
-
-        tmutil = getThemeManager()
-        viewer = getMultiAdapter((element, request), IViewer)
-        return viewer(location=element, engine=engine, canvas_mode=canvas_mode)
-
-    def editElement(self, id, name, value):
-        """Edit the element: assign a value to an attribute (name).
-        """
-        element = self._getElementById(id)
-        element.name = value
-
-    def copyElement(self, id):
-        """Copy an element to the clipboard.
-        """
-        request = self.request
-        element = self._getElementById(id)
-        container = getParent(element)
-        request.form['ids'] = [zapi.name(element)]
-        view = Contents(container, request)
-        view.copyObjects()
-
-    def pasteElement(self, id):
-        """Paste an element from the clipboard.
-        """
-        request = self.request
-        element = self._getElementById(id)
-        container = getParent(element)
-        view = Contents(container, request)
-        view.pasteObjects()
-
-    def addElement(self, id, type_name, order):
-        """Add an element in a container.
-        Return the id of added element.
-        """
-        request = self.request
-        container = self._getElementById(id)
-
-        factory = zapi.getUtility(IFactory, type_name)
-        content = factory()
-        notify(ObjectCreatedEvent(content))
-
-        adding = getMultiAdapter((container, request), INodeAdding)
-
-        added = adding.add(content)
-        added_id = added.identifier
-        self.reorderElement(added_id, int(order))
-        return added_id
-
-    def moveElement(self, src_id, dest_id, order):
-        """Move an element to another destination element.
-        return the id of the moved element.
-        """
-        request = self.request
-        element = self._getElementById(src_id)
-        dest_container = self._getElementById(dest_id)
-        # move the element to the destination container
-        moving = getMultiAdapter((dest_container, request), INodeMoving)
-        moved = moving.move(element)
-
-        # move the element to the specified order
-        moved_id = moved.identifier
-        self.reorderElement(moved_id, int(order))
-        return moved_id
-
-    def reorderElement(self, id, order):
-        """Move an element to a new position.
-        """
-        element = self._getElementById(id)
-        container = getParent(element)
-        ordering = getMultiAdapter((container, self.request), INodeOrdering)
-        ordering.reorder(element, int(order))
-
-    def deleteElement(self, id):
-        """Delete the element specified by its path.
-        """
-        request = self.request
-        element = self._getElementById(id)
-        container = getParent(element)
-        removing = getMultiAdapter((container, request), INodeRemoving)
-        removing.remove(element)
-
-    def duplicateElement(self, id):
-        """Duplicate an element specified by its id.
-        Return the id of the duplicated element.
-        """
-        request = self.request
-        element = self._getElementById(id)
-        container = getParent(element)
-        duplicating = getMultiAdapter((container, request), INodeDuplicating)
-        return duplicating.duplicate(element)
-
-    def getCanvasMode(self):
-        """Get the canvas view mode
-        """
-        return Editor.getCanvasMode()
+# This is a package

Added: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/authoring.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/authoring.py     
Sat Oct 29 13:05:28 2005
@@ -0,0 +1,155 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.app.publisher.browser import BrowserView
+from zope.app.session.interfaces import ISession
+from zope.app.zapi import getMultiAdapter
+from zope.component import adapts
+from zope.interface import implements, Interface
+from zope.security.proxy import removeSecurityProxy
+
+from cpsskins.elements.interfaces import IElement
+from cpsskins.elements.interfaces import IPresentable, IDisplayable, 
IFormattable
+from cpsskins.browser.elements.interfaces import INodeAdding, INodeRemoving
+from cpsskins.browser.elements.interfaces import INodeMoving, INodeOrdering
+from cpsskins.browser.elements.interfaces import INodeDuplicating
+from cpsskins.browser.rendering.interfaces import IViewer
+from cpsskins.thememanager import getThemeManager
+
+class IAuthoring(Interface):
+
+    def draw():
+        """ """
+
+    def getCanvasMode():
+        """ """
+
+    def setCanvasMode(mode):
+        """ """
+
+    def setPerspective(perspective):
+        """ """
+
+    def cloneView(id, format):
+        """ """
+
+    def addView(perspective):
+        """ """
+
+    def removeView(perspective):
+        """ """
+
+class Authoring(BrowserView):
+    adapts(IElement)
+    implements(IAuthoring)
+
+    def _redirect(self):
+        request = self.request
+        target = request.get('HTTP_REFERER', '.')
+        request.response.redirect(target)
+
+    def draw(self, **kw):
+        """Draws a the canvas element in edit mode
+        """
+        viewer = getMultiAdapter((self.context, self.request), IViewer)
+        return viewer(**kw)
+
+    def getCanvasMode(self):
+        """Get the canvas view mode
+        """
+        request = self.request
+        pkg_id = 'cpsskins'
+        session = ISession(request)[pkg_id]
+        try:
+            mode = session['canvas_mode']
+        except KeyError:
+            mode = None
+        return mode
+
+    def setCanvasMode(self, mode=None):
+        """Set the canvas view mode
+        """
+        pkg_id = 'cpsskins'
+        session = ISession(self.request)[pkg_id]
+        if mode is not None:
+            session['canvas_mode'] = mode
+        self._redirect()
+
+    def setPerspective(self, perspective=''):
+        """Set the perspective
+        """
+        pkg_id = 'cpsskins'
+        session = ISession(self.request)[pkg_id]
+
+        if not perspective:
+            del session['perspective']
+        else:
+            tmutil = getThemeManager()
+            theme = tmutil.getEffectiveTheme(self.context)
+            perspective = theme.getPerspectiveById(perspective)
+
+            # remove the security proxy before storing the object in the 
session
+            perspective = removeSecurityProxy(perspective)
+            session['perspective'] = perspective
+        self._redirect()
+
+    def clonePresentation(self, perspective=None):
+        """Clone a view in a given perspective by:
+
+        - assigning a new display to it
+
+        - by associating the original display's formats to the new display
+
+        """
+        tmutil = getThemeManager()
+        theme = tmutil.getEffectiveTheme(self.context)
+        perspective = theme.getPerspectiveById(perspective)
+        display = IDisplayable(self.context).getDisplay(perspective)
+        if display is None:
+            IPresentable(self.context).clonePresentation(perspective)
+        self._redirect()
+
+    def addPresentation(self, perspective=None):
+        tmutil = getThemeManager()
+        theme = tmutil.getEffectiveTheme(self.context)
+        perspective = theme.getPerspectiveById(perspective)
+        IPresentable(self.context).addPresentation(perspective)
+        self._redirect()
+
+    def removePresentation(self, perspective=None):
+        tmutil = getThemeManager()
+        theme = tmutil.getEffectiveTheme(self.context)
+        perspective = theme.getPerspectiveById(perspective)
+        IPresentable(self.context).removePresentation(perspective)
+        self._redirect()
+
+    def customizeFormat(self, name='', perspective=None):
+        tmutil = getThemeManager()
+        theme = tmutil.getEffectiveTheme(self.context)
+        perspective = theme.getPerspectiveById(perspective)
+        IPresentable(self.context).customizeFormat(name, perspective)
+        self._redirect()
+
+    def uncustomizeFormat(self, name='', perspective=None):
+        tmutil = getThemeManager()
+        theme = tmutil.getEffectiveTheme(self.context)
+        perspective = theme.getPerspectiveById(perspective)
+        IPresentable(self.context).uncustomizeFormat(name, perspective)
+        self._redirect()
+

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/configure.zcml   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/configure.zcml   
Sat Oct 29 13:05:28 2005
@@ -32,7 +32,7 @@
       for="cpsskins.elements.interfaces.ITheme"
       layer="cpsskins"
       permission="zope.Public"
-      class=".Authoring">
+      class=".authoring.Authoring">
 
     <page
         name="content-authoring.html"
@@ -54,7 +54,7 @@
       for="cpsskins.elements.interfaces.IThemePage"
       layer="cpsskins"
       permission="zope.Public"
-      class=".Authoring">
+      class=".authoring.Authoring">
 
     <page
         name="page-authoring.html"
@@ -123,7 +123,7 @@
       for="cpsskins.elements.IElement"
       layer="cpsskins"
       permission="zope.ManageContent"
-      class=".Authoring">
+      class=".authoring.Authoring">
 
       <page
           name="getCanvasMode"
@@ -167,66 +167,6 @@
 
   </pages>
 
-
-  <!-- Editing pages -->
-
-  <resource
-      name="editing.css" file="editing.css"
-      layer="cpsskins" />
-
-  <page
-      for="*"
-      name="edit-panel.html"
-      permission="zope.Public"
-      template="edit_panel.pt"
-      class=".Editing"
-  />
-
-  <page
-      for="*"
-      name="edit-menu.html"
-      permission="zope.Public"
-      template="edit_menu.pt"
-      class=".Editing"
-  />
-
-  <page
-      for="*"
-      name="edit-control.html"
-      permission="zope.Public"
-      template="edit_control.pt"
-      class=".Editing"
-  />
-
-  <pages
-      for="cpsskins.elements.IElement"
-      layer="cpsskins"
-      permission="zope.ManageContent"
-      class=".Editing">
-
-      <page
-          name="getId"
-          attribute="getId"
-      />
-
-      <page
-          name="getPath"
-          attribute="getPath"
-      />
-
-      <page
-          name="getParent"
-          attribute="getParent"
-      />
-
-      <page
-          name="getIcon"
-          attribute="getIcon"
-      />
-
-  </pages>
-
-
   <!-- Presentation editor -->
 
   <page
@@ -243,11 +183,6 @@
       layer="cpsskins" />
 
 
-  <!-- Filters -->
-
-  <include package=".filters" />
-
-
   <!-- Style editor -->
 
   <resource
@@ -266,58 +201,12 @@
       layer="cpsskins" />
 
 
-  <!-- Canvas element editor -->
-
-  <editform
-      schema="cpsskins.elements.interfaces.ITheme"
-      for="cpsskins.elements.interfaces.ITheme"
-      layer="cpsskins"
-      name="edit.html"
-      template="edit.pt"
-      permission="zope.ManageContent"
-  />
-
-  <editform
-      schema="cpsskins.elements.interfaces.IThemePage"
-      for="cpsskins.elements.interfaces.IThemePage"
-      layer="cpsskins"
-      name="edit.html"
-      template="edit.pt"
-      permission="zope.ManageContent"
-  />
-
-  <editform
-      schema="cpsskins.elements.interfaces.IPageBlock"
-      for="cpsskins.elements.interfaces.IPageBlock"
-      layer="cpsskins"
-      name="edit.html"
-      template="edit.pt"
-      permission="zope.ManageContent"
-  />
-
-  <editform
-      schema="cpsskins.elements.interfaces.ICell"
-      for="cpsskins.elements.interfaces.ICell"
-      layer="cpsskins"
-      name="edit.html"
-      template="edit.pt"
-      permission="zope.ManageContent"
-  />
-
-  <editform
-      schema="cpsskins.elements.interfaces.ISlot"
-      for="cpsskins.elements.interfaces.ISlot"
-      layer="cpsskins"
-      name="edit.html"
-      template="edit.pt"
-      permission="zope.ManageContent"
-  />
 
 
   <!-- JSON-RPC views -->
 
   <jsonrpc:view
-      class=".Methods"
+      class=".jsonrpc.Methods"
       for="*"
       permission="zope.ManageContent"
       methods="addElement editElement moveElement
@@ -325,7 +214,7 @@
   />
 
   <jsonrpc:view
-      class=".Methods"
+      class=".jsonrpc.Methods"
       for="*"
       permission="zope.Public"
       methods="renderElement getCanvasMode"

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/interfaces.py    
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/interfaces.py    
Sat Oct 29 13:05:28 2005
@@ -19,39 +19,3 @@
 
 from zope.interface import Interface
 
-class IEditing(Interface):
-
-    def getId():
-        """ """
-
-    def getPath():
-        """ """
-
-    def getParent():
-        """ """
-
-    def getIcon():
-        """ """
-
-class IAuthoring(Interface):
-
-    def draw():
-        """ """
-
-    def getCanvasMode():
-        """ """
-
-    def setCanvasMode(mode):
-        """ """
-
-    def setPerspective(perspective):
-        """ """
-
-    def cloneView(id, format):
-        """ """
-
-    def addView(perspective):
-        """ """
-
-    def removeView(perspective):
-        """ """

Added: z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/jsonrpc.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/jsonrpc.py       
Sat Oct 29 13:05:28 2005
@@ -0,0 +1,159 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.app import zapi
+from zope.app.container.browser.contents import Contents
+from zope.app.event.objectevent import ObjectCreatedEvent
+from zope.app.location.traversing import LocationPhysicallyLocatable
+from zope.app.publisher.browser import BrowserView
+from zope.app.session.interfaces import ISession
+from zope.app.traversing.api import getParent
+from zope.app.zapi import queryMultiAdapter, getMultiAdapter
+from zope.component import adapts
+from zope.component.interfaces import IFactory
+from zope.event import notify
+from zope.interface import implements
+from zope.security.proxy import removeSecurityProxy
+
+from jsonserver.interfaces import IJSONRPCPublisher
+
+from cpsskins.elements.interfaces import IElement
+from cpsskins.elements.interfaces import IPresentable, IDisplayable, 
IFormattable
+from cpsskins.browser.elements.interfaces import INodeAdding, INodeRemoving
+from cpsskins.browser.elements.interfaces import INodeMoving, INodeOrdering
+from cpsskins.browser.elements.interfaces import INodeDuplicating
+from cpsskins.browser.rendering.interfaces import IViewer
+from cpsskins.thememanager import getThemeManager
+
+class Methods(object):
+    """JSON-RPC methods.
+    """
+    implements(IJSONRPCPublisher)
+
+    def __init__(self, context, request):
+        request.form = {}
+        self.context = context
+        self.request = request
+
+    def _getElementById(self, id):
+        """Return an element by id.
+        """
+        tmutil = getThemeManager()
+        return tmutil.getElementById(id)
+
+    def renderElement(self, id, engine='default', canvas_mode=''):
+        """Render the element and return the markup
+        """
+        element = self._getElementById(id)
+        request = self.request
+
+        tmutil = getThemeManager()
+        viewer = getMultiAdapter((element, request), IViewer)
+        return viewer(location=element, engine=engine, canvas_mode=canvas_mode)
+
+    def editElement(self, id, name, value):
+        """Edit the element: assign a value to an attribute (name).
+        """
+        element = self._getElementById(id)
+        element.name = value
+
+    def copyElement(self, id):
+        """Copy an element to the clipboard.
+        """
+        request = self.request
+        element = self._getElementById(id)
+        container = getParent(element)
+        request.form['ids'] = [zapi.name(element)]
+        view = Contents(container, request)
+        view.copyObjects()
+
+    def pasteElement(self, id):
+        """Paste an element from the clipboard.
+        """
+        request = self.request
+        element = self._getElementById(id)
+        container = getParent(element)
+        view = Contents(container, request)
+        view.pasteObjects()
+
+    def addElement(self, id, type_name, order):
+        """Add an element in a container.
+        Return the id of added element.
+        """
+        request = self.request
+        container = self._getElementById(id)
+
+        factory = zapi.getUtility(IFactory, type_name)
+        content = factory()
+        notify(ObjectCreatedEvent(content))
+
+        adding = getMultiAdapter((container, request), INodeAdding)
+
+        added = adding.add(content)
+        added_id = added.identifier
+        self.reorderElement(added_id, int(order))
+        return added_id
+
+    def moveElement(self, src_id, dest_id, order):
+        """Move an element to another destination element.
+        return the id of the moved element.
+        """
+        request = self.request
+        element = self._getElementById(src_id)
+        dest_container = self._getElementById(dest_id)
+        # move the element to the destination container
+        moving = getMultiAdapter((dest_container, request), INodeMoving)
+        moved = moving.move(element)
+
+        # move the element to the specified order
+        moved_id = moved.identifier
+        self.reorderElement(moved_id, int(order))
+        return moved_id
+
+    def reorderElement(self, id, order):
+        """Move an element to a new position.
+        """
+        element = self._getElementById(id)
+        container = getParent(element)
+        ordering = getMultiAdapter((container, self.request), INodeOrdering)
+        ordering.reorder(element, int(order))
+
+    def deleteElement(self, id):
+        """Delete the element specified by its path.
+        """
+        request = self.request
+        element = self._getElementById(id)
+        container = getParent(element)
+        removing = getMultiAdapter((container, request), INodeRemoving)
+        removing.remove(element)
+
+    def duplicateElement(self, id):
+        """Duplicate an element specified by its id.
+        Return the id of the duplicated element.
+        """
+        request = self.request
+        element = self._getElementById(id)
+        container = getParent(element)
+        duplicating = getMultiAdapter((container, request), INodeDuplicating)
+        return duplicating.duplicate(element)
+
+    def getCanvasMode(self):
+        """Get the canvas view mode
+        """
+        return Editor.getCanvasMode()

Modified: z3lab/cpsskins/branches/jmo-perspectives/browser/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/browser/configure.zcml     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/configure.zcml     Sat Oct 
29 13:05:28 2005
@@ -184,6 +184,8 @@
 
   <include package=".elements" />
 
+  <include package=".editing" />
+
   <include package=".authoring" />
 
   <include package=".rendering" />

Added: z3lab/cpsskins/branches/jmo-perspectives/browser/editing/__init__.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/editing/__init__.py        
Sat Oct 29 13:05:28 2005
@@ -0,0 +1 @@
+# This is a package

Added: z3lab/cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/editing/configure.zcml     
Sat Oct 29 13:05:28 2005
@@ -0,0 +1,111 @@
+<configure
+    xmlns="http://namespaces.zope.org/browser";
+    xmlns:zope="http://namespaces.zope.org/zope";>
+
+  <!--.editing.Editing pages -->
+
+  <resource
+      name="editing.css" file="editing.css"
+      layer="cpsskins" />
+
+  <page
+      for="*"
+      name="edit-panel.html"
+      permission="zope.Public"
+      template="edit_panel.pt"
+      class=".editing.Editing"
+  />
+
+  <page
+      for="*"
+      name="edit-menu.html"
+      permission="zope.Public"
+      template="edit_menu.pt"
+      class=".editing.Editing"
+  />
+
+  <page
+      for="*"
+      name="edit-control.html"
+      permission="zope.Public"
+      template="edit_control.pt"
+      class=".editing.Editing"
+  />
+
+  <pages
+      for="cpsskins.elements.IElement"
+      layer="cpsskins"
+      permission="zope.ManageContent"
+      class=".editing.Editing">
+
+      <page
+          name="getId"
+          attribute="getId"
+      />
+
+      <page
+          name="getPath"
+          attribute="getPath"
+      />
+
+      <page
+          name="getParent"
+          attribute="getParent"
+      />
+
+      <page
+          name="getIcon"
+          attribute="getIcon"
+      />
+
+  </pages>
+
+  <include package=".filters" />
+
+  <!-- Canvas element editor -->
+
+  <editform
+      schema="cpsskins.elements.interfaces.ITheme"
+      for="cpsskins.elements.interfaces.ITheme"
+      layer="cpsskins"
+      name="edit.html"
+      template="edit.pt"
+      permission="zope.ManageContent"
+  />
+
+  <editform
+      schema="cpsskins.elements.interfaces.IThemePage"
+      for="cpsskins.elements.interfaces.IThemePage"
+      layer="cpsskins"
+      name="edit.html"
+      template="edit.pt"
+      permission="zope.ManageContent"
+  />
+
+  <editform
+      schema="cpsskins.elements.interfaces.IPageBlock"
+      for="cpsskins.elements.interfaces.IPageBlock"
+      layer="cpsskins"
+      name="edit.html"
+      template="edit.pt"
+      permission="zope.ManageContent"
+  />
+
+  <editform
+      schema="cpsskins.elements.interfaces.ICell"
+      for="cpsskins.elements.interfaces.ICell"
+      layer="cpsskins"
+      name="edit.html"
+      template="edit.pt"
+      permission="zope.ManageContent"
+  />
+
+  <editform
+      schema="cpsskins.elements.interfaces.ISlot"
+      for="cpsskins.elements.interfaces.ISlot"
+      layer="cpsskins"
+      name="edit.html"
+      template="edit.pt"
+      permission="zope.ManageContent"
+  />
+</configure>

Added: z3lab/cpsskins/branches/jmo-perspectives/browser/editing/editing.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/browser/editing/editing.py Sat Oct 
29 13:05:28 2005
@@ -0,0 +1,76 @@
+##############################################################################
+#
+# Copyright (c) 2005 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.app.location.traversing import LocationPhysicallyLocatable
+from zope.app.publisher.browser import BrowserView
+from zope.app.traversing.api import getParent
+from zope.app.zapi import queryMultiAdapter
+from zope.component import adapts
+from zope.interface import implements, Interface
+
+from cpsskins.elements.interfaces import IElement
+from cpsskins.elements.interfaces import IPresentable, IDisplayable, 
IFormattable
+from cpsskins.browser.elements.interfaces import INodeAdding, INodeRemoving
+from cpsskins.browser.elements.interfaces import INodeMoving, INodeOrdering
+from cpsskins.browser.elements.interfaces import INodeDuplicating
+from cpsskins.browser.rendering.interfaces import IViewer
+
+class IEditing(Interface):
+
+    def getId():
+        """ """
+
+    def getPath():
+        """ """
+
+    def getParent():
+        """ """
+
+    def getIcon():
+        """ """
+
+class Editing(BrowserView):
+
+    adapts(IElement)
+    implements(IEditing)
+
+    def getId(self):
+        """Return the element's id
+        """
+        return self.context.identifier
+
+    def getPath(self):
+        """Return the element's path
+        """
+        return LocationPhysicallyLocatable(self.context).getPath()
+
+    def getParent(self):
+        """Return the element's path
+        """
+        return getParent(self.context)
+
+    def getIcon(self):
+        """Return the element's icon path
+        """
+        icon_url = ''
+        icon = queryMultiAdapter((self.context, self.request), name='zmi_icon')
+        if icon:
+            icon_url = icon.url()
+        return icon_url
+

Copied: 
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/configure.zcml 
(from r28795, 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/configure.zcml)
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/browser/authoring/filters/configure.zcml
   (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/browser/editing/filters/configure.zcml 
    Sat Oct 29 13:05:28 2005
@@ -43,7 +43,6 @@
       factory=".content.EditorFilter"
   />
 
-
   <!-- Theme Page -->
 
   <page
@@ -51,7 +50,7 @@
       name="editor (layout)"
       template="themepage_edit_layout.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
 
@@ -62,7 +61,7 @@
       name="editor (layout)"
       template="pageblock_edit_layout.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
 
@@ -73,7 +72,7 @@
       name="editor (layout)"
       template="cell_edit_layout.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
 
@@ -84,7 +83,7 @@
       name="editor (page authoring)"
       template="page/slot_edit.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
   <page
@@ -92,7 +91,7 @@
       name="editor (content authoring)"
       template="content/slot_edit.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
 
@@ -103,7 +102,7 @@
       name="editor (page authoring)"
       template="page/portlet_edit.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
   <page
@@ -111,7 +110,7 @@
       name="editor (content authoring)"
       template="content/portlet_edit.pt"
       permission="zope.Public"
-      class="..Editing"
+      class="..editing.Editing"
   />
 
 </configure>
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to