Author: jmorliaguet
Date: Sat Nov 26 16:37:34 2005
New Revision: 1937

Modified:
   cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
   cpsskins/branches/jmo-perspectives/browser/editing/portlet_editor.pt
   cpsskins/branches/jmo-perspectives/browser/negociation/configure.zcml
   cpsskins/branches/jmo-perspectives/browser/negociation/interfaces.py
   cpsskins/branches/jmo-perspectives/browser/negociation/views.py
   cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
   cpsskins/branches/jmo-perspectives/interfaces.py
   cpsskins/branches/jmo-perspectives/thememanager.py
Log:

- move getEffectivePage / getEffectiveTheme to browser.negociation

  TODO: convert pages to view methods



Modified: cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt     Sat Nov 
26 16:37:34 2005
@@ -5,7 +5,7 @@
                 perspective context/@@getPerspective;
                 format_name request/form/format|string:;
                 location request/form/location|nothing;
-                current_theme python:tmutil.getEffectiveTheme(context);
+                current_theme context/@@getEffectiveTheme;
                 displayable context/displayable:this;
                 actual_display python: displayable.getDisplay(perspective);
                 display python: displayable.getEffectiveDisplay(perspective);

Modified: cpsskins/branches/jmo-perspectives/browser/editing/portlet_editor.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/portlet_editor.pt        
(original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/portlet_editor.pt        
Sat Nov 26 16:37:34 2005
@@ -2,7 +2,7 @@
   <head>
     <tal:style metal:fill-slot="style"
                define="tmutil context/@@getThemeManager;
-                       current_theme 
python:tmutil.getEffectiveTheme(context);">
+                       current_theme context/@@getEffectiveTheme">
       <link rel="Stylesheet" type="text/css"
             href="/++skin++cpsskins/@@/++resource++widgets.css" />
       <style type="text/css" media="all"

Modified: cpsskins/branches/jmo-perspectives/browser/negociation/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negociation/configure.zcml       
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negociation/configure.zcml       
Sat Nov 26 16:37:34 2005
@@ -27,6 +27,21 @@
     />
 
     <page
+        name="getEffectiveTheme"
+        attribute="getEffectiveTheme"
+    />
+
+    <page
+        name="getEffectivePage"
+        attribute="getEffectivePage"
+    />
+
+    <page
+        name="getThemeInContext"
+        attribute="getThemeInContext"
+    />
+
+    <page
         name="getPerspective"
         attribute="getPerspective"
     />

Modified: cpsskins/branches/jmo-perspectives/browser/negociation/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negociation/interfaces.py        
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negociation/interfaces.py        
Sat Nov 26 16:37:34 2005
@@ -27,6 +27,20 @@
     def getDefaultPageView():
         """ """
 
+    def getEffectiveTheme(context, request):
+        """Return the effective theme
+        (the one that will be effectively displayed)"""
+
+    def getEffectivePage(context, request):
+        """Return the effective page
+        (the one that will be effectively displayed)"""
+
+    def getThemeInContext(context, request):
+        """Return the theme in which the element is located.
+
+        A context must be provided with.
+        """
+
     def getPerspective():
         """ """
 

Modified: cpsskins/branches/jmo-perspectives/browser/negociation/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/negociation/views.py     
(original)
+++ cpsskins/branches/jmo-perspectives/browser/negociation/views.py     Sat Nov 
26 16:37:34 2005
@@ -20,7 +20,9 @@
 from zope.app import zapi
 from zope.app.publisher.browser import BrowserView
 from zope.app.session.interfaces import ISession
+from zope.component import queryUtility
 
+from cpsskins.elements.interfaces import ITheme, IThemePage
 from cpsskins.browser.rendering.interfaces import IViewer
 from cpsskins.utils import getThemeManager
 
@@ -37,6 +39,40 @@
         page = tmutil.getDefaultPage()
         return zapi.getMultiAdapter((page, self.request), IViewer)
 
+    ###################################################################
+    # Themes and pages
+    ###################################################################
+
+    def getEffectiveTheme(self):
+        """Return the effective theme
+        (the one that will be effectively displayed)
+        """
+        return self.getThemeInContext() or \
+               getThemeManager().getDefaultTheme()
+
+    def getEffectivePage(self):
+        """Return the effective page
+        (the one that will be effectively displayed)
+        """
+        context = self.context
+        # use the contextual page (e.g. in editor mode)
+        if IThemePage.providedBy(context):
+            return context
+        # use the default page
+        return getThemeManager().getDefaultPage()
+
+    def getThemeInContext(self):
+        """Return the theme in a given context.
+        """
+        context = self.context
+        if ITheme.providedBy(context):
+            return context
+        return queryUtility(ITheme, context=context)
+
+    ###################################################################
+    # Perspectives
+    ###################################################################
+
     def getPerspective(self):
         pkg_id = 'cpsskins'
         session = ISession(self.request)[pkg_id]
@@ -46,5 +82,10 @@
             perspective = None
         return perspective
 
+    ###################################################################
+    # Engines
+    ###################################################################
+
     def getEffectiveEngine(self):
         return self.request.annotations.get('cpsskins.engine', 'default')
+

Modified: 
cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt
==============================================================================
--- cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt    
(original)
+++ cpsskins/branches/jmo-perspectives/engines/authoring/authoring_macros.pt    
Sat Nov 26 16:37:34 2005
@@ -147,8 +147,8 @@
 <metal:block define-slot="doctype"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 
1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";></metal:block>
 <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"
   tal:define="tmutil context/@@getThemeManager;
-              current_theme python:tmutil.getEffectiveTheme(context);
-              effective_page python:tmutil.getEffectivePage(context, request)">
+              current_theme context/@@getEffectiveTheme;
+              effective_page context/@@getEffectivePage">
   <head>
     <metal:block define-slot="css" />
     <link rel="Stylesheet" type="text/css"

Modified: cpsskins/branches/jmo-perspectives/interfaces.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/interfaces.py    (original)
+++ cpsskins/branches/jmo-perspectives/interfaces.py    Sat Nov 26 16:37:34 2005
@@ -60,20 +60,6 @@
     def getDefaultPage():
         """Return the default page."""
 
-    def getEffectiveTheme(context, request):
-        """Return the effective theme
-        (the one that will be effectively displayed)"""
-
-    def getEffectivePage(context, request):
-        """Return the effective page
-        (the one that will be effectively displayed)"""
-
-    def getThemeInContext(context, request):
-        """Return the theme in which the element is located.
-
-        A context must be provided with.
-        """
-
     def removeDisplays(object):
         """Remove the display of an element
         """

Modified: cpsskins/branches/jmo-perspectives/thememanager.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/thememanager.py  (original)
+++ cpsskins/branches/jmo-perspectives/thememanager.py  Sat Nov 26 16:37:34 2005
@@ -144,8 +144,11 @@
         res = relations.search(predicate=isDefault, first=object)
         return res is not []
 
-    ###################################################################
-    # TODO: this should be a view
+    def setAsDefault(self, object=None):
+        """Set the default theme
+        """
+        relations = getUtility(IRelationStorage, context=object)
+        relations.add(MonadicRelation(isDefault, object))
 
     def getDefaultTheme(self):
         """ """
@@ -162,36 +165,8 @@
                 return page
         return None
 
-    def getEffectiveTheme(self, context=None, request=None):
-        """Return the effective theme
-        (the one that will be effectively displayed)
-        """
-        return self.getThemeInContext(context) or self.getDefaultTheme()
-
-    def getEffectivePage(self, context=None, request=None):
-        """Return the effective page
-        (the one that will be effectively displayed)
-        """
-        # use the contextual page (e.g. in editor mode)
-        if IThemePage.providedBy(context):
-            return context
-        # use the default page
-        return self.getDefaultPage()
-
-    def getThemeInContext(self, context=None, request=None):
-        """Return the theme in a given context.
-        """
-        if ITheme.providedBy(context):
-            return context
-        return queryUtility(ITheme, context=context)
-
-    ####################################################################
-
-    def setAsDefault(self, object=None):
-        """Set the default theme
-        """
-        relations = getUtility(IRelationStorage, context=object)
-        relations.add(MonadicRelation(isDefault, object))
+    ###################################################################
+    # TODO: this should be a view
 
     ###################################################################
     # Displays
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to