[Zope3-checkins] CVS: Zope3/src/zope/app/site/browser - metaconfigure.py:1.2

Stephan Richter srichter at cosmos.phy.tufts.edu
Sun Mar 21 19:52:25 EST 2004


Update of /cvs-repository/Zope3/src/zope/app/site/browser
In directory cvs.zope.org:/tmp/cvs-serv1385/src/zope/app/site/browser

Modified Files:
	metaconfigure.py 
Log Message:


Added servicetool directive; removed view factories in favor of type based
classes.




=== Zope3/src/zope/app/site/browser/metaconfigure.py 1.1 => 1.2 ===
--- Zope3/src/zope/app/site/browser/metaconfigure.py:1.1	Sun Mar 21 11:02:18 2004
+++ Zope3/src/zope/app/site/browser/metaconfigure.py	Sun Mar 21 19:52:24 2004
@@ -17,22 +17,73 @@
 """
 from zope.publisher.interfaces.browser import IBrowserRequest, IBrowserPublisher
 from zope.app.component.metaconfigure import view, interface as ifaceDirective
+from zope.app.publisher.browser.viewmeta import view as complexView
 
 from zope.app.site.interfaces import ISiteManager
-from tools import UtilityToolsViewFactory, IUtilityToolsView, IToolType
+from tools import IToolView, IUtilityToolView, IToolType
+from tools import UtilityToolAdding, UtilityToolView
+from tools import ServiceToolView, ServiceToolAdding
+from zope.app.site.interfaces import ILocalService
 
 def tool(_context, interface, folder="tools", title=None, description=None):
-
-    factory = UtilityToolsViewFactory(interface, folder, title, description)
     name = "manage" + interface.getName() + "Tool.html"
+    addName = "Add" + interface.getName() + "Tool"
+    
     permission = 'zope.ManageContent'
 
-
     ifaceDirective(_context, interface, IToolType)
 
-    view(_context, [factory], IBrowserRequest, name, [ISiteManager],
+    class_ = type("UtilityToolView for %s" % interface.getName(),
+                  (UtilityToolView,),
+                  {'interface':interface,
+                   'folder':folder,
+                   'title':title,
+                   'description':description})
+    
+    view(_context, [class_], IBrowserRequest, name, [ISiteManager],
+         permission=permission,
+         allowed_interface=[IUtilityToolView, IBrowserPublisher],
+         allowed_attributes=['__call__', '__getitem__'])
+
+    class_ = type("UtilityToolAdding for %s" % interface.getName(),
+                  (UtilityToolAdding,),
+                  {'_addFilterInterface': interface,
+                   'folder':folder,
+                   'title':'Add %s Tool' % interface.getName()} )
+
+    addView = complexView(_context, ISiteManager, permission, addName,
+                          class_=class_)
+    addView.page(_context, 'index.html', 'index')
+    addView.page(_context, 'action.html', 'action')
+
+    addView()
+
+def servicetool(_context, folder="tools", title=None, description=None):
+    name = "manageILocalServiceTool.html"
+    addName = "AddServiceTool"
+    
+    permission = 'zope.ManageContent'
+
+    ifaceDirective(_context, ILocalService, IToolType)
+
+    class_ = type("ServiceToolView",
+                  (ServiceToolView,),
+                  {'folder':folder,
+                   'title':title,
+                   'description':description})
+    
+    view(_context, [class_], IBrowserRequest, name, [ISiteManager],
          permission=permission,
-         allowed_interface=[IUtilityToolsView, IBrowserPublisher],
+         allowed_interface=[IToolView, IBrowserPublisher],
          allowed_attributes=['__call__', '__getitem__'])
 
+    class_ = type("ServiceToolAdding",
+                  (ServiceToolAdding,),
+                  {'folder':folder} )
+
+    addView = complexView(_context, ISiteManager, permission, addName,
+                          class_=class_)
+    addView.page(_context, 'index.html', 'index')
+    addView.page(_context, 'action.html', 'action')
 
+    addView()




More information about the Zope3-Checkins mailing list