Author: jmorliaguet
Date: Sat Dec  3 11:24:59 2005
New Revision: 1950

Modified:
   cpsskins/branches/jmo-perspectives/browser/editing/edit_menu.pt
   cpsskins/branches/jmo-perspectives/browser/editing/views.py
Log:

- optimizations / code cleanup



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 Dec 
 3 11:24:59 2005
@@ -2,15 +2,12 @@
   <body metal:fill-slot="body"
     class="panel" i18n:domain="cpsskins"
     tal:define="tmutil context/@@getThemeManager;
-                negociation nocall:context/@@negociation;
-                perspective negociation/getPerspective;
-                format_name request/form/format|string:;
-                displayable context/displayable:this;
-                display python: displayable.getEffectiveDisplay(perspective);
-                formattable display/formattable:this|nothing;
-                here_url context/@@absolute_url;
-                edited_url formattable/?format_name/@@absolute_url|here_url;
-                main_url context/@@editpanel/getMainUrl"
+                info context/@@editpanel/getInfo;
+                perspective nocall:info/perspective;
+                negociation nocall:info/negociation;
+                format_name info/format_name;
+                display nocall:info/display;
+                main_url info/main_url"
     tal:attributes="onload python: main_url and
                    'parent.main.location.href = \'%s\'' % main_url
                     or 'parent.main.location.reload()'">
@@ -22,7 +19,7 @@
 
       <!-- edit element -->
       <li>
-        <a tal:attributes="class python: here_url == edited_url and
+        <a tal:attributes="class python: info['element']['selected'] and
                           'itemselected' or 'item'" i18n:translate=""
            href="@@edit-menu.html?main_url=@@edit.html">
           <img src="" tal:attributes="src context/@@getIcon" />
@@ -32,7 +29,7 @@
 
       <!-- edit formats -->
       <tal:block condition="python: display is not None">
-        <li tal:define="formats formattable/getFormats"
+        <li tal:define="formats info/formats"
             tal:condition="formats"
             tal:repeat="format formats">
           <a i18n:translate=""

Modified: cpsskins/branches/jmo-perspectives/browser/editing/views.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/browser/editing/views.py (original)
+++ cpsskins/branches/jmo-perspectives/browser/editing/views.py Sat Dec  3 
11:24:59 2005
@@ -87,33 +87,45 @@
 
 class EditPanel(BrowserView):
 
-    def getMainUrl(self):
+    def getAbsoluteURL(self, object):
+        return getMultiAdapter((object, self.request), name='absolute_url')()
+
+    def getInfo(self):
         context = self.context
         request = self.request
 
         form = request.form
-        if 'main_url' in form:
-            return form['main_url']
+        main_url = form.get('main_url')
+        format_name = form.get('format')
 
         negociation = getMultiAdapter((context, request),
                                       INegociation, 'negociation')
         perspective = negociation.getPerspective()
 
-        main = context
-
-        if 'format' in form:
-            format_name = form['format']
-            display = IDisplayable(context).getEffectiveDisplay(perspective)
-            format = IFormattable(display).getFormat(format_name)
-            if format is not None:
-                main = format
-
-        base_url = getMultiAdapter((main, request),
-                                    name='absolute_url')() + '/'
-
-        main_url = base_url + form.get('action', '@@edit.html')
-        return main_url
-
+        displayable = IDisplayable(context)
+        display = displayable.getEffectiveDisplay(perspective)
+        formattable = IFormattable(display)
+        formats = formattable.getFormats()
+        format = format_name and formattable.getFormat(format_name) or None
+        main = format is not None and format or context
+
+        base_url = self.getAbsoluteURL(main) + '/'
+        main_url = main_url or base_url + form.get('action', '@@edit.html')
+
+        element_info = {
+            'selected': not format,
+            }
+
+        return {
+            'negociation': negociation,
+            'perspective': perspective,
+            'format_name': format_name,
+            'display': display,
+            'format': format,
+            'formats': formats,
+            'main_url': main_url,
+            'element': element_info,
+            }
 
 #######################################################################
 # Settings
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to