[Zope-CVS] CVS: Products/CompositePage - composite.py:1.13 designuis.py:1.6 element.py:1.2 interfaces.py:1.8

Shane Hathaway shane at zope.com
Tue Mar 2 18:41:17 EST 2004


Update of /cvs-repository/Products/CompositePage
In directory cvs.zope.org:/tmp/cvs-serv25987

Modified Files:
	composite.py designuis.py element.py interfaces.py 
Log Message:
Template selection in the manual UI is now functional.


=== Products/CompositePage/composite.py 1.12 => 1.13 ===
--- Products/CompositePage/composite.py:1.12	Tue Mar  2 17:08:45 2004
+++ Products/CompositePage/composite.py	Tue Mar  2 18:40:46 2004
@@ -221,12 +221,23 @@
             slot_values = slot.objectValues()
             for element in slot_values:
                 error = None
+                template = None
+                templates = ()
                 try:
                     ob = element.dereference()
+                    template = element.getInlineTemplate()
+                    templates = element.listAllowableInlineTemplates()
                 except:
                     error = formatException(self, editing=1)
                     ob = FailedElement().__of__(self)
                 icon = getIconURL(ob, icon_base_url)
+                available_templates = []
+                for name, t in templates:
+                    if hasattr(aq_base(t), 'title_or_id'):
+                        title = t.title_or_id()
+                    else:
+                        title = name
+                    available_templates.append({'id': name, 'title': title})
                 element_info = {
                     'title': ob.title_or_id(),
                     'icon': icon,
@@ -236,8 +247,8 @@
                     'next_index': index + 1,
                     'can_move_up': (index > 0),
                     'can_move_down': (index < len(slot_values) - 1),
-                    'template': 'xxx',
-                    'available_templates': ('yyy', 'zzz'),
+                    'template': template,
+                    'available_templates': available_templates,
                     }
                 elements.append(element_info)
                 index += 1


=== Products/CompositePage/designuis.py 1.5 => 1.6 ===
--- Products/CompositePage/designuis.py:1.5	Tue Mar  2 15:41:44 2004
+++ Products/CompositePage/designuis.py	Tue Mar  2 18:40:46 2004
@@ -148,6 +148,8 @@
         """
         root = self.getPhysicalRoot()
         obj = root.restrictedTraverse(path)
+        if ICompositeElement.isImplementedBy(obj):
+            obj = obj.dereference()
         RESPONSE.redirect("%s/%s" % (
             obj.absolute_url(), self.workspace_view_name))
 
@@ -158,6 +160,8 @@
         """
         root = self.getPhysicalRoot()
         obj = root.restrictedTraverse(path)
+        if ICompositeElement.isImplementedBy(obj):
+            obj = obj.dereference()
         RESPONSE.redirect(obj.absolute_url())
 
 
@@ -207,21 +211,23 @@
             m = guarded_getattr(ob, "listAllowableInlineTemplates")
             templates = m()
             d = {}
-            for template in templates:
-                d[template] = 1
+            for name, template in templates:
+                d[name] = template
             if all_choices is None:
                 all_choices = d
             else:
                 for template in all_choices.keys():
                     if not d.has_key(template):
                         del all_choices[template]
-        templates = all_choices.keys()
-        templates.sort()
-        return {"obs": obs, "templates": templates, "current_template": current}
+        return {
+            "obs": obs,
+            "templates": all_choices,
+            "current_template": current,
+            }
 
 
     security.declarePublic("changeTemplate")
-    def changeTemplate(self, paths, template, REQUEST=None):
+    def changeTemplate(self, paths, template, reload=0, close=1, REQUEST=None):
         """Changes the template for objects.
         """
         info = self.getTemplateChangeInfo(paths)
@@ -233,7 +239,10 @@
             m = guarded_getattr(ob, "setInlineTemplate")
             m(template)
         if REQUEST is not None:
-            return close_dialog_html
+            if reload:
+                REQUEST["RESPONSE"].redirect(REQUEST["HTTP_REFERER"])
+            elif close:
+                return close_dialog_html
 
 Globals.InitializeClass(CommonUI)
 


=== Products/CompositePage/element.py 1.1 => 1.2 ===
--- Products/CompositePage/element.py:1.1	Tue Mar  2 15:41:44 2004
+++ Products/CompositePage/element.py	Tue Mar  2 18:40:46 2004
@@ -89,7 +89,11 @@
         """
         tool = aq_get(self, "composite_tool", None, 1)
         if tool is not None:
-            return tool.default_inline_templates
+            res = []
+            for name in tool.default_inline_templates:
+                template = obj.restrictedTraverse(str(name))
+                res.append((name, template))
+            return res
         # No tool found, so no inline templates are known.
         return ()
 


=== Products/CompositePage/interfaces.py 1.7 => 1.8 ===
--- Products/CompositePage/interfaces.py:1.7	Tue Mar  2 15:41:44 2004
+++ Products/CompositePage/interfaces.py	Tue Mar  2 18:40:46 2004
@@ -83,7 +83,9 @@
         """
 
     def listAllowableInlineTemplates():
-        """Returns a list of inline template names allowable for this object.
+        """Returns a list of templates allowable for this object.
+
+        Returns a list of (template_name, template_object).
         """
 
     def dereference():




More information about the Zope-CVS mailing list