[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZMI/tests - testProvideClass.py:1.1.2.9 testServiceProvideClass.py:1.1.2.10 testTabsDirective.py:1.1.2.10 testZMIViewUtility.py:1.1.2.12
Jim Fulton
jim@zope.com
Fri, 7 Jun 2002 10:41:50 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZMI/tests
In directory cvs.zope.org:/tmp/cvs-serv12187/lib/python/Zope/App/ZMI/tests
Modified Files:
Tag: Zope-3x-branch
testProvideClass.py testServiceProvideClass.py
testTabsDirective.py testZMIViewUtility.py
Log Message:
Merging in Zope3InWonderland-branch, which implemented the following
proposals (see
http://dev.zope.org/Wikis/DevSite/Projects/ComponentArchitecture/OldProposals):
- RenameAllowToRequire
- GroupClassRelatedDirectivesInClassDirective
- ViewInterfaceAndSimplification
- ConsistentUseOfSpacesAsDelimitersInZCMLAttributes
- TwoArgumentViewConstructors
- ImplementsInZCML
- SimpleViewCreationInZCML
- RemoveGetView
- ReplaceProtectWithAllow
- ViewMethodsAsViews
- MergeProtectionAndComponentDefinitions
There were also various security fixes resulting of better integration
of security with components.
=== Zope3/lib/python/Zope/App/ZMI/tests/testProvideClass.py 1.1.2.8 => 1.1.2.9 ===
from Zope.App.ZMI import provideClass
- provideClass("AddableContent", 'My.Test.Addable', MyAddableObject,
- None, 'Testing')
+ provideClass(registry="AddableContent",
+ qualified_name="My.Test.Addable",
+ _class=MyAddableObject,
+ permission=None,
+ title='Testing')
- object = getService(None, "Factories").createObject('My.Test.Addable')
- self.assert_(isinstance(object, MyAddableObject))
+ obj = getService(None, "Factories").createObject('My.Test.Addable')
+ self.assert_(isinstance(obj, MyAddableObject))
def test_suite():
=== Zope3/lib/python/Zope/App/ZMI/tests/testServiceProvideClass.py 1.1.2.9 => 1.1.2.10 ===
-import unittest, sys, Interface
+import unittest, sys, Interface, os
from Zope.App.ZMI import provideClass
-
from StringIO import StringIO
from Zope.Configuration.xmlconfig import xmlconfig
-from Zope.App.OFS.Services.AddableService.tests.AddableSetup import AddableSetup
+from Zope.App.OFS.Services.AddableService.tests.AddableSetup \
+ import AddableSetup
from Zope.Configuration.xmlconfig import ZopeXMLConfigurationError
from Zope.ComponentArchitecture import getService
+import Zope.App.ZMI
+defs_path = os.path.join(
+ os.path.split(Zope.App.ZMI.__file__)[0],
+ 'zmi-meta.zcml')
class MyAddableService:
@@ -34,6 +38,10 @@
class ServiceProvideClassTest(AddableSetup, unittest.TestCase):
+ def setUp(self):
+ AddableSetup.setUp(self)
+ xmlconfig(open(defs_path))
+
def testServiceProvideClassDirective(self):
serviceName = (
'Zope.App.ZMI.tests.testServiceProvideClass.MyAddableService')
@@ -41,21 +49,16 @@
xmlconfig( StringIO('''
<zopeConfigure
xmlns="http://namespaces.zope.org/zope"
- xmlns:service="http://namespaces.zope.org/zmi/service">
-
- <directives namespace="http://namespaces.zope.org/zmi/service">
- <directive name="factoryFromClass"
- attributes="name, permission_id, title, description"
- handler="Zope.App.ZMI.metaConfigure.ServiceClassDir" />
- </directives>
+ xmlns:service="http://namespaces.zope.org/service">
- <service:factoryFromClass name="%s"
+ <service:factoryFromClass
+ id="%s"
class="%s"
- permission_id="Zope.AddService"
+ permission="Zope.AddService"
title="Stupid Service"
description="This is a sample Service" />
- </zopeConfigure>
+ </zopeConfigure>
''' %(serviceName, serviceName)))
addables = getService(None,"AddableServices").getAddables(None)
=== Zope3/lib/python/Zope/App/ZMI/tests/testTabsDirective.py 1.1.2.9 => 1.1.2.10 ===
namespace="http://namespaces.zope.org/zmi"
handler="Zope.App.ZMI.TabsDirective.">
- <subdirective name="tab" attributes="label,action,filter" />
+ <subdirective name="tab" attributes="label action filter" />
</directive>
<zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I1">
<zmi:tab label="Edit" action="edit" />
@@ -83,7 +83,7 @@
<directive name="tabs" attributes="for"
namespace="http://namespaces.zope.org/zmi"
handler="Zope.App.ZMI.TabsDirective.">
- <subdirective name="tab" attributes="label,action,filter" />
+ <subdirective name="tab" attributes="label action filter" />
</directive>
<zmi:tabs for="Zope.App.ZMI.tests.sampleInterfaces.I1">
<zmi:tab label="Edit" action="edit" />
=== Zope3/lib/python/Zope/App/ZMI/tests/testZMIViewUtility.py 1.1.2.11 => 1.1.2.12 ===
import PlacefulSetup
from Zope.App.ZMI.ZMIViewUtility import ZMIViewUtility
-from Zope.Publisher.Browser.IBrowserPublisher import IBrowserPublisher
+from Zope.Publisher.Browser.IBrowserView import IBrowserView
+from Zope.Publisher.Browser.IBrowserPresentation import IBrowserPresentation
from Zope.App.ZopePublication.Traversers import TestTraverser
from Zope.Security.SecurityManagement import setSecurityPolicy
from Zope.Security.SecurityManagement import newSecurityManager
@@ -39,7 +40,7 @@
return [('l1', 'a1'),
('l2', 'a2/a3'),
('lbad', 'abad'),
- ('l3', 'a3;view'),]
+ ('l3', 'view::a3'),]
class I(Interface): pass
class C:
@@ -53,8 +54,11 @@
ob.abad.bad=1
class V:
- def __init__(self, context): pass
- __implements__ = IBrowserPublisher
+ __implements__ = IBrowserView
+
+ def __init__(self, context, request):
+ self.context = context
+ self.request = request
class Test(PlacefulSetup, unittest.TestCase):
@@ -65,26 +69,26 @@
provideService=getServiceManager(None).provideService
defineService('ZMIViewService', IZMIViewService)
provideService('ZMIViewService', Service())
- getService(None,"Views").provideView(I, 'a3', IBrowserPublisher, V)
+ getService(None,"Views").provideView(
+ I, 'a3', IBrowserPresentation, [V])
getService(None, "Views").provideView(None, '_traverse',
- IBrowserPublisher, TestTraverser)
+ IBrowserPresentation, [TestTraverser])
defineChecker(C, NamesChecker(['a1', 'a2', 'a3'], CheckerPublic,
abad='waaa'))
def test(self):
newSecurityManager('who')
- v = ZMIViewUtility(ProxyFactory(ob))
- v.setViewRequest(Request())
+ v = ZMIViewUtility(ProxyFactory(ob), Request())
self.assertEqual(v.getZMIViews(),
- [{'label':'l1', 'action':'../a1'},
- {'label':'l2', 'action':'../a2/a3'},
- {'label':'l3', 'action':'../a3;view'}
+ [{'label':'l1', 'action':'a1'},
+ {'label':'l2', 'action':'a2/a3'},
+ {'label':'l3', 'action':'view::a3'}
])
class Request:
- def getViewType(self):
- return IBrowserPublisher
- def getViewSkin(self):
+ def getPresentationType(self):
+ return IBrowserPresentation
+ def getPresentationSkin(self):
return ''
def test_suite():