Bonsoir,
Je viens de créer un patch pour la classe FlexibleTypeInformation qui permet de récupérer le rendered de chaque layout d'un type de document de façon séparée dans un dictionnaire.
Cela est utile si on souhaite (comme c'est le cas sur notre projet) afficher les layouts dans 2 colonnes séparées ou autre.
 
Je soumet donc ce patch à la sagacité de Nuxéo.
 
Cordialement

Cédric Marfil
Concepteur Réalisateur Intégrateur Confirmé
Tél. direct: 03.20.65.34.82
Mail: [EMAIL PROTECTED]

Capgemini
181 rue Jules Delcenserie
59700 Marcq en Baroeul
This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

Index: 
D:/CMarfil/ApplicationsRepository/ECLIPSE/01.GAGNER_zopeInstance01/Products/CPSDocument/FlexibleTypeInformation.py
===================================================================
--- 
D:/CMarfil/ApplicationsRepository/ECLIPSE/01.GAGNER_zopeInstance01/Products/CPSDocument/FlexibleTypeInformation.py
  (revision 11898)
+++ 
D:/CMarfil/ApplicationsRepository/ECLIPSE/01.GAGNER_zopeInstance01/Products/CPSDocument/FlexibleTypeInformation.py
  (working copy)
@@ -722,10 +722,46 @@
             all_rendered += rendered
         return all_rendered
 
+
     #
     # API
     #
 
+
+    security.declareProtected(View, 'renderLayoutsList')
+    def renderLayoutsList(self, layout_structures, datastructure, context,
+                       no_form=False, **kw):
+        """
+            Method that renders each layout separately to use them as you wish
+        """
+        layout_mode = kw['layout_mode']
+        all_rendered = {}
+        nb_layouts = len(layout_structures)
+        flexible_layouts = self._getFlexibleLayouts()
+        for i, layout_structure in enumerate(layout_structures):
+            if no_form:
+                # We don't want to generate form header/footer
+                first_layout = last_layout = False
+            else:
+                # find if is the first/last layout
+                first_layout = (i == 0)
+                last_layout = (i == nb_layouts-1)
+            is_flexible = layout_mode != 'create' and \
+                          layout_structure['layout_id'] in flexible_layouts
+            # Render layout structure.
+            layout = layout_structure['layout']
+            layout.renderLayoutStructure(layout_structure, datastructure, **kw)
+            # Apply layout style.
+            rendered = layout.renderLayoutStyle(layout_structure,
+                                                datastructure, context,
+                                                first_layout=first_layout,
+                                                last_layout=last_layout,
+                                                is_flexible=is_flexible,
+                                                **kw)
+            all_rendered[layout.getId()] = rendered
+            
+        return all_rendered
+
     security.declareProtected(View, 'renderObject')
     def renderObject(self, ob, layout_mode='view', layout_id=None,
                      cluster=None, request=None, context=None,
@@ -751,6 +787,32 @@
         return self._renderLayouts(layout_structures, ds, context,
                                    layout_mode=layout_mode, **kw)
 
+    security.declareProtected(View, 'renderObjectList')
+    def renderObjectList(self, ob, layout_mode='view', layout_id=None,
+                     cluster=None, request=None, context=None,
+                     use_session=False, **kw):
+        """Render the object.
+
+        The datastructure information comes from the object, and, if
+        available, the request (to be able to pass explicit values in
+        the URL) and the session (if use_session is true).
+
+        ``context`` is used to find the layout method.
+        """
+        proxy = kw.get('proxy')
+        dm = self.getDataModel(ob, proxy=proxy, context=context)
+        ds = DataStructure(datamodel=dm)
+
+        layout_structures = self._computeLayoutStructures(
+            ds, layout_mode, layout_id=layout_id, cluster=cluster,
+            ob=ob, request=request, use_session=use_session)
+
+        if context is None:
+            context = ob
+        return self.renderLayoutsList(layout_structures, ds, context,
+                                      layout_mode=layout_mode, **kw)
+
+
     security.declareProtected(View, 'validateObject')
     def validateObject(self, ob, layout_mode='edit', layout_id=None,
                        cluster=None, request=None, use_session=False,
_______________________________________________
cps-users-fr 
Adresse de la liste : [email protected]
Gestion de l'abonnement : <http://lists.nuxeo.com/mailman/listinfo/cps-users-fr>

Répondre à