[Zope3-checkins] SVN: Zope3/branches/ZopeX3-3.0/src/zope/app/ Use
zapi.isinstance() as appropriate.
Fred L. Drake, Jr.
fdrake at gmail.com
Tue Aug 31 21:59:33 EDT 2004
Log message for revision 27378:
Use zapi.isinstance() as appropriate.
Always use zapi.isinstance(o) instead of isinstance(removeSecurityProxy(o))
when the unproxied object is not otherwise needed.
Changed:
U Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_factory.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/interface/vocabulary.py
U Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
-=-
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_factory.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_factory.py 2004-08-31 23:53:45 UTC (rev 27377)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/component/tests/test_factory.py 2004-09-01 01:59:33 UTC (rev 27378)
@@ -21,7 +21,6 @@
from zope.configuration.xmlconfig import xmlconfig
from zope.configuration.xmlconfig import XMLConfig
from zope.component import createObject
-from zope.security.proxy import removeSecurityProxy
from zope.app.tests.placelesssetup import PlacelessSetup
from zope.app import zapi
@@ -64,9 +63,7 @@
</content>''')
xmlconfig(f)
obj = createObject(None, 'test.Example')
- # isinstance() doesn't work with proxies, so remove if present
- obj = removeSecurityProxy(obj)
- self.failUnless(isinstance(obj, ExampleClass))
+ self.failUnless(zapi.isinstance(obj, ExampleClass))
def test_suite():
loader=unittest.TestLoader()
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/interface/vocabulary.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/interface/vocabulary.py 2004-08-31 23:53:45 UTC (rev 27377)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/interface/vocabulary.py 2004-09-01 01:59:33 UTC (rev 27378)
@@ -50,8 +50,7 @@
"""
def __init__(self, context):
- component = removeSecurityProxy(context)
- interfaces = providedBy(component).flattened()
+ interfaces = providedBy(context).flattened()
terms = [SimpleTerm(interface, interfaceToName(context, interface))
for interface in interfaces]
super(ObjectInterfacesVocabulary, self).__init__(terms)
Modified: Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py
===================================================================
--- Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-08-31 23:53:45 UTC (rev 27377)
+++ Zope3/branches/ZopeX3-3.0/src/zope/app/publisher/browser/tests/test_directoryresource.py 2004-09-01 01:59:33 UTC (rev 27378)
@@ -99,14 +99,13 @@
resource = DirectoryResourceFactory(path, checker, 'files')(request)
image = resource['test.gif']
- self.assert_(isinstance(removeSecurityProxy(image), FileResource))
+ self.assert_(zapi.isinstance(image, FileResource))
template = resource['test.pt']
- self.assert_(isinstance(removeSecurityProxy(template),
- PageTemplateResource))
+ self.assert_(zapi.isinstance(template, PageTemplateResource))
file = resource['test.txt']
- self.assert_(isinstance(removeSecurityProxy(file), FileResource))
+ self.assert_(zapi.isinstance(file, FileResource))
file = resource['png']
- self.assert_(isinstance(removeSecurityProxy(file), FileResource))
+ self.assert_(zapi.isinstance(file, FileResource))
def test_suite():
return makeSuite(Test)
More information about the Zope3-Checkins
mailing list