[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/ZopePublication/tests - testSimpleComponentTraverser.py:1.1.2.1 testZopePublication.py:1.1.2.26 testDefaultTraverser.py:NONE
Jim Fulton
jim@zope.com
Thu, 23 May 2002 14:01:51 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/ZopePublication/tests
In directory cvs.zope.org:/tmp/cvs-serv26429/lib/python/Zope/App/ZopePublication/tests
Modified Files:
Tag: Zope-3x-branch
testZopePublication.py
Added Files:
Tag: Zope-3x-branch
testSimpleComponentTraverser.py
Removed Files:
Tag: Zope-3x-branch
testDefaultTraverser.py
Log Message:
This all started with wanting to be able to use url;view in a ZPT path. :)
That lead me to:
- Massive traversal refactoring.
Namespace handling is now centralized in Zope.App.Traversing.
- ZPT refactoring, including some renaming that touches pretty much everything. :)
- The application specific ZPT support was moved into
Zope.App.PageTemplate.
- To get page template files (for use in views):
from Zope.App.PageTemplate import ViewPageTemplateFile
- Fixed up security so that ZPT expressions only have access to
safe builtins and so that modules namespace does imports safely.
- Got ZPTPage working!
- renaming url to absolute_url and got absolute_url to work in paths.
- Cleaned up the (as yet unused) RestrictedInterpreter module in
Zope.Security. In particular, changed to use a separate
RestrictedBuiltins module.
=== Added File Zope3/lib/python/Zope/App/ZopePublication/tests/testSimpleComponentTraverser.py ===
##############################################################################
#
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""
$Id: testSimpleComponentTraverser.py,v 1.1.2.1 2002/05/23 18:01:20 jim Exp $
"""
import unittest, sys
from Zope.ComponentArchitecture.tests.Request import Request
from Zope.App.ZopePublication.Traversers import SimpleComponentTraverser
from Zope.ComponentArchitecture import getService
from Interface import Interface
from Zope.Exceptions import NotFoundError
from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
class I(Interface): pass
class Container:
def __init__(self, **kw):
for k in kw:
setattr(self, k , kw[k])
def getObject(self, name, default=None):
return getattr(self, name, default)
class Request(Request):
def getEffectiveURL(self):
return ''
class View:
def __init__(self, comp):
self._comp = comp
class Test(PlacelessSetup, unittest.TestCase):
def testAttr(self):
""" test container traver """
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
T = SimpleComponentTraverser(c)
self.assertRaises(NotFoundError , T.publishTraverse, req ,'foo')
def testView(self):
""" test getting a view """
foo = Container()
c = Container( foo=foo )
req = Request( I, '')
T = SimpleComponentTraverser(c)
getService(None,"Views").provideView(None , 'foo', I, View)
self.failUnless(T.publishTraverse(req,'foo').__class__ is View )
self.assertRaises(NotFoundError , T.publishTraverse, req ,'morebar')
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(Test)
if __name__=='__main__':
unittest.TextTestRunner().run(test_suite())
=== Zope3/lib/python/Zope/App/ZopePublication/tests/testZopePublication.py 1.1.2.25 => 1.1.2.26 ===
from ZODB.MappingStorage import MappingStorage
from Zope.Publisher.Exceptions import Retry
+from Zope.App.ZopePublication.Traversers import TestTraverser
from Zope.Security import SimpleSecurityPolicies
from Zope.Security.SecurityManagement import setSecurityPolicy
-from Zope.App.ZopePublication.Traversers import DefaultTraverser
from Interface import Interface
from Interface.Verify import verifyClass
from Interface.Implements import instancesOfObjectImplements
@@ -158,7 +158,7 @@
getService(None,'Views').setDefaultViewName(I1,
IBrowserPublisher, 'view')
getService(None, 'Views').provideView(None,
- '_traverse', IBrowserPublisher, DefaultTraverser)
+ '_traverse', IBrowserPublisher, TestTraverser)
ob = O1()
@@ -293,7 +293,7 @@
ob = C()
r = self._createRequest('/x',pub)
provideView=getService(None, "Views").provideView
- provideView(None, '_traverse', IBrowserPublisher, DefaultTraverser)
+ provideView(None, '_traverse', IBrowserPublisher, TestTraverser)
ob2 = pub.traverseName(r, ob, 'x')
self.assertEqual(removeAllProxies(ob2).v, 1)
self.assertEqual(getWrapperContext(ob2), ob)
=== Removed File Zope3/lib/python/Zope/App/ZopePublication/tests/testDefaultTraverser.py ===