[Zope3-checkins] CVS: Zope3/lib/python/Zope/App/ZMI - StandardMacros.py:1.3 configure.zcml:1.9

Steve Alexander steve@cat-box.net
Mon, 28 Oct 2002 06:21:14 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI
In directory cvs.zope.org:/tmp/cvs-serv24555

Modified Files:
	StandardMacros.py configure.zcml 
Log Message:
Made StandardMacros work by seeking pages with macros by name, rather
than by directly importing the PageTemplate files.
Added view_macros and dialog_macros back in as views.


=== Zope3/lib/python/Zope/App/ZMI/StandardMacros.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/App/ZMI/StandardMacros.py:1.2	Tue Oct 22 15:34:59 2002
+++ Zope3/lib/python/Zope/App/ZMI/StandardMacros.py	Mon Oct 28 06:21:13 2002
@@ -17,26 +17,36 @@
 
 $Id$
 """
-from ZMIViewUtility import ZMIViewUtility
-from Zope.App.PageTemplate.ViewPageTemplateFile import ViewPageTemplateFile
+from ZMIViewUtility import ZMIViewUtility, IZMIViewUtility
+from Zope.ComponentArchitecture import getView
 
 class Macros:
 
     macro_pages = ()
 
     def __getitem__(self, key):
-        for page in self.macro_pages:
-            v = page.macros.get(key)
-            if v is not None:
+        context = self.context
+        request = self.request
+        for name in self.macro_pages:
+            page = getView(context, name, request)
+            try:
+                v = page[key]
+            except KeyError:
+                pass
+            else:
                 return v
         raise KeyError, key
+    
+
+class IStandardMacros(IZMIViewUtility):
+
+    def __getitem__(key):
+        """Return the macro named 'key'"""
+
 
 class StandardMacros(ZMIViewUtility, Macros):
 
-    __implements__ = ZMIViewUtility.__implements__
+    __implements__ = IStandardMacros
 
-    macro_pages = (
-            ViewPageTemplateFile('www/view_macros.pt'),
-            ViewPageTemplateFile('www/dialog_macros.pt')
-            )
+    macro_pages = ('view_macros', 'dialog_macros')
 


=== Zope3/lib/python/Zope/App/ZMI/configure.zcml 1.8 => 1.9 ===
--- Zope3/lib/python/Zope/App/ZMI/configure.zcml:1.8	Tue Oct 22 15:34:59 2002
+++ Zope3/lib/python/Zope/App/ZMI/configure.zcml	Mon Oct 28 06:21:13 2002
@@ -9,7 +9,16 @@
 
   <browser:view name="standard_macros"
                 permission="Zope.View"
-                factory=".StandardMacros." />
+                factory=".StandardMacros." 
+                allowed_interface=".StandardMacros.IStandardMacros" />
+
+  <browser:view name="view_macros"
+                permission="Zope.View"
+                template="www/view_macros.pt" />
+
+  <browser:view name="dialog_macros"
+                permission="Zope.View"
+                template="www/dialog_macros.pt" />
 
   <browser:view name="ZMIUtility"
                 permission="Zope.View"