Author: jmorliaguet
Date: Sat Nov 12 00:47:04 2005
New Revision: 29474

Added:
   z3lab/cpsskins/branches/jmo-perspectives/settings.py   (contents, props 
changed)
Removed:
   z3lab/cpsskins/branches/jmo-perspectives/registry/
   z3lab/cpsskins/branches/jmo-perspectives/storage/README.txt
   z3lab/cpsskins/branches/jmo-perspectives/storage/perspectives.py
Modified:
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
   
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
   z3lab/cpsskins/branches/jmo-perspectives/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py
   z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py
   
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
   z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
   z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml
   z3lab/cpsskins/branches/jmo-perspectives/thememanager.py
Log:

- saving work:

  - added a site management folder under the theme management folder to 
    store local settings

  - perspectives can be registered as local settings




Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/configure.zcml
  Sat Nov 12 00:47:04 2005
@@ -1,20 +1,15 @@
 <configure
-    xmlns="http://namespaces.zope.org/zope";>
+    xmlns="http://namespaces.zope.org/zope";
+    xmlns:browser="http://namespaces.zope.org/browser";>
 
+  <localUtility class=".perspective.Perspective">
 
-  <content class=".perspective.Perspective">
+      <require
+          permission="zope.ManageServices"
+          interface=".perspective.IPerspective"
+      />
 
-    <require
-        permission="zope.View"
-        interface=".perspective.IPerspective"
-        />
-
-    <require
-        permission="zope.ManageContent"
-        set_schema=".perspective.IPerspective"
-        />
-
-  </content>
+  </localUtility>
 
   <adapter
       factory=".perspective.Resource"

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
  (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/configuration/perspectives/perspective.py
  Sat Nov 12 00:47:04 2005
@@ -22,6 +22,9 @@
 from zope.interface import implements, Interface, Attribute
 from zope.schema import DottedName, TextLine
 
+from persistent import Persistent
+from zope.app.container.contained import Contained
+
 from cpsskins import interfaces
 from cpsskins.configuration.interfaces import IResource
 
@@ -30,7 +33,7 @@
 
     resource = Attribute("The actual data.")
 
-class Perspective(object):
+class Perspective(Persistent, Contained):
     """A perspective configuration item.
     """
     implements(IPerspective)

Modified: z3lab/cpsskins/branches/jmo-perspectives/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/configure.zcml     (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/configure.zcml     Sat Nov 12 
00:47:04 2005
@@ -50,6 +50,21 @@
 
   </content>
 
+  <localUtility class=".settings.Settings">
+
+    <require
+        permission="zope.ManageSite"
+        interface=".interfaces.ISettings"
+        set_schema=".interfaces.ISettings"
+        />
+
+    <require
+        permission="zope.ManageSite"
+        
interface="zope.app.component.interfaces.registration.IRegisterableContainer"
+        />
+
+  </localUtility>
+
   <!-- Package includes -->
 
   <include package=".controllers" />
@@ -70,8 +85,6 @@
 
   <include package=".configuration" />
 
-  <include package=".registry" />
-
   <include package=".storage" />
 
 </configure>

Modified: z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/controllers/theme.py       Sat Nov 
12 00:47:04 2005
@@ -45,3 +45,5 @@
         if tmutil.getDefaultTheme() is None:
             tmutil.setAsDefault(element)
 
+        # XXX for testing
+       element.addPerspective(name='local', title='Local perspective')

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py   
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/presentation.py   Sat Nov 
12 00:47:04 2005
@@ -148,7 +148,7 @@
 
         # set initial values
         for perspective in theme.listPerspectives():
-            view_name = perspective['name']
+            view_name = perspective.name
             views[view_name] = {
                 'relation': None,
                 'display': None,

Modified: z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py  (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/elements/theme.py  Sat Nov 12 
00:47:04 2005
@@ -17,8 +17,9 @@
 """
 __docformat__ = "reStructuredText"
 
-from zope.app.component.site import SiteManagementFolder
 from zope.app.container.interfaces import INameChooser
+from zope.app.component.interfaces.registration import ActiveStatus
+from zope.app.component.site import SiteManagementFolder, UtilityRegistration
 from zope.component import adapts, queryUtility, getUtilitiesFor
 from zope.interface import implements
 
@@ -26,7 +27,7 @@
 from cpsskins.configuration.interfaces import IResource
 from cpsskins.elements.interfaces import IElement, INode, INodeTraverser
 from cpsskins.perspectives.interfaces import IPerspective
-from cpsskins.storage.interfaces import IPerspectiveStorage
+from cpsskins.perspectives import Perspective
 from cpsskins.thememanager import getThemeManager
 from interfaces import ITheme, IThemePage
 from interfaces import IPageContainer
@@ -88,24 +89,31 @@
 
     def getPerspectiveById(self, id):
         """Return a perspective by id."""
-        item = queryUtility(configuration.IPerspective, id)
+        item = queryUtility(configuration.IPerspective, id, context=self)
         if item is None:
             return None
         return IResource(item).getResource()
 
-    def addPerspective(self, object):
+    def addPerspective(self, name, title):
         """Add a perspective to the perspective storage
         """
-        perspectives = self.getStorage(IPerspectiveStorage)
-        chooser = INameChooser(perspectives)
-        name = chooser.chooseName(str(object), object)
-        perspectives[name] = object
+        perspective = Perspective(name=name, title=title)
+        settings = getThemeManager()['settings']
+
+        chooser = INameChooser(settings)
+        name = chooser.chooseName(name, perspective)
+        settings[name] = configuration.Perspective(resource=perspective)
+
+        reg = UtilityRegistration(name, configuration.IPerspective,
+                                  settings[name])
+        settings.registrationManager.addRegistration(reg)
+        reg.status = ActiveStatus
 
     def listPerspectives(self):
         info = []
         for name, item in getUtilitiesFor(configuration.IPerspective):
             resource = IResource(item).getResource()
-            info.append({'name': resource.name, 'title': resource.title})
+            info.append(resource)
         return info
 
 class NodeTraverser(object):

Modified: 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
==============================================================================
--- 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt  
    (original)
+++ 
z3lab/cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt  
    Sat Nov 12 00:47:04 2005
@@ -50,7 +50,7 @@
       <option tal:repeat="perspective perspectives"
               tal:content="perspective/title"
               tal:attributes="value perspective/name;
-                              selected python:perspective['name'] == current
+                              selected python:perspective.name == current
                                        and 'selected' or nothing" />
     </select>
   </form>

Modified: z3lab/cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/interfaces.py      Sat Nov 12 
00:47:04 2005
@@ -94,3 +94,6 @@
 
     def __setitem__(key, value):
         """ """
+
+class ISettings(Interface):
+    """ """

Added: z3lab/cpsskins/branches/jmo-perspectives/settings.py
==============================================================================
--- (empty file)
+++ z3lab/cpsskins/branches/jmo-perspectives/settings.py        Sat Nov 12 
00:47:04 2005
@@ -0,0 +1,27 @@
+##############################################################################
+#
+# 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.component.site import SiteManagementFolder
+from zope.interface import implements
+
+from interfaces import ISettings
+
+class Settings(SiteManagementFolder):
+
+    implements(ISettings)

Modified: z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml     
(original)
+++ z3lab/cpsskins/branches/jmo-perspectives/storage/configure.zcml     Sat Nov 
12 00:47:04 2005
@@ -54,16 +54,6 @@
   />
 
 
-  <!-- Perspective storage -->
-
-  <cpsskins:storage
-      id="perspectives"
-      title="Perspective storage"
-      description="A perspective storage"
-      factory=".perspectives.PerspectiveStorage"
-  />
-
-
   <!-- Some basic views -->
 
   <browser:containerViews

Modified: z3lab/cpsskins/branches/jmo-perspectives/thememanager.py
==============================================================================
--- z3lab/cpsskins/branches/jmo-perspectives/thememanager.py    (original)
+++ z3lab/cpsskins/branches/jmo-perspectives/thememanager.py    Sat Nov 12 
00:47:04 2005
@@ -27,7 +27,8 @@
 from zope.interface import implements
 
 from caching import ImageCache
-from interfaces import IThemeManagement, IImageCache
+from settings import Settings
+from interfaces import IThemeManagement, IImageCache, ISettings
 from elements.interfaces import ITheme, IThemeContainer, IThemePage
 from elements.interfaces import IFormattable
 from ontology import isDefault, hasFormat
@@ -38,8 +39,6 @@
 from storage.interfaces import IRelationStorage
 
 THEMES_MANAGER_NAME = 'themes'
-UIDS_NAME = 'uids'
-IMAGE_CACHE_NAME = 'imagecache'
 
 def added(object, event):
     object.registerUtilities()
@@ -63,12 +62,14 @@
 
     def __init__(self):
         super(ThemeManagement, self).__init__()
-        self[UIDS_NAME] = IntIds()
-        self[IMAGE_CACHE_NAME] = ImageCache()
+        self['uids'] = IntIds()
+        self['imagecache'] = ImageCache()
+        self['settings'] = Settings()
 
     def registerUtilities(self):
-        self.registerUtility(IIntIds, self[UIDS_NAME])
-        self.registerUtility(IImageCache, self[IMAGE_CACHE_NAME])
+        self.registerUtility(IIntIds, self['uids'])
+        self.registerUtility(IImageCache, self['imagecache'])
+        self.registerUtility(ISettings, self['settings'])
 
     def registerUtility(self, interface, utility):
         reg = UtilityRegistration('', interface, utility)
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to