[Zope-Checkins] SVN: Zope/branches/2.9/ - Fix #2155: Wrong parameters being passed to logger's error().
Log message for revision 69658: - Fix #2155: Wrong parameters being passed to logger's error(). Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/ZPublisher/BeforeTraverse.py A Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2006-08-18 16:10:19 UTC (rev 69657) +++ Zope/branches/2.9/doc/CHANGES.txt 2006-08-18 16:34:06 UTC (rev 69658) @@ -16,6 +16,9 @@ - Usage of 'urljoin' in 'webdav.davcmds' could lead to wrongly constructed urls. + - Collector #2155: Fix wrong parameter being passed to +logger's error() method, with tests. + Zope 2.9.4 (2006/07/21) Bugs fixed Modified: Zope/branches/2.9/lib/python/ZPublisher/BeforeTraverse.py === --- Zope/branches/2.9/lib/python/ZPublisher/BeforeTraverse.py 2006-08-18 16:10:19 UTC (rev 69657) +++ Zope/branches/2.9/lib/python/ZPublisher/BeforeTraverse.py 2006-08-18 16:34:06 UTC (rev 69658) @@ -13,10 +13,9 @@ __version__='$Revision: 1.12 $'[11:-2] BeforeTraverse interface and helper classes -import logging +import logging from Acquisition import aq_base -import sys # Interface @@ -105,7 +104,7 @@ cob(container, request) except TypeError: self.logger.error('%s call %s failed.' % ( -`self._hookname`, `cob`), error=sys.exc_info()) +`self._hookname`, `cob`), exc_info=True) def add(self, cob): self._list.append(cob) @@ -151,6 +150,5 @@ # Only catch exceptions that are likely to be logic errors. # We shouldn't catch Redirects, Unauthorizeds, etc. since # the programmer may want to raise them deliberately. -import sys self.logger.error('Error while invoking hook: %s' -% self.name, error=sys.exc_info()) +% self.name, exc_info=True) Added: Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py === --- Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py 2006-08-18 16:10:19 UTC (rev 69657) +++ Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py 2006-08-18 16:34:06 UTC (rev 69658) @@ -0,0 +1,153 @@ +import sys +import logging + +from Acquisition import Implicit +from ZPublisher import BeforeTraverse +from ZPublisher.BaseRequest import BaseRequest +from ZPublisher.HTTPResponse import HTTPResponse + +def makeBaseRequest(root): +response = HTTPResponse() +environment = { 'URL': '', + 'PARENTS': [root], + 'steps': [], + '_hacked_path': 0, + '_test_counter': 0, + 'response': response } +return BaseRequest(environment) + + +class DummyObjectBasic(Implicit): + Dummy class with docstring. + +pass + + +class BrokenHook: + +def __call__(self, *args): + print self.__class__.__name__, 'called' + raise TypeError, self.__class__.__name__ + +def testBeforeTraverse(self): + +Zope supports a 'before traverse' hook that is used for several +features, including 'Site Access Rules'. It is implemented using a +special API for registering hooks, and the hooks themselves are +called during traversal by ZPublisher. + + root = DummyObjectBasic() + request = makeBaseRequest(root) + + container = DummyObjectBasic() + root.container = container + + obj = DummyObjectBasic() + container.obj = obj + +Setup a broken hook as the before traverse hook for the +container. That will create a 'MultiHook' object: + + BeforeTraverse.registerBeforeTraverse(container, BrokenHook(), +...'broken_hook') + + container.__before_publishing_traverse__ +ZPublisher.BeforeTraverse.MultiHook instance at ... + + container.__before_traverse__ +{(99, 'broken_hook'): ZPublisher.tests.testBeforeTraverse.BrokenHook ...} + +Setup logging so we can see the actual exception being logged: + + logger = logging.getLogger('MultiHook') + level = logger.level + handlers = logger.handlers[:] + + logger.addHandler(logging.StreamHandler(sys.stdout)) + logger.setLevel(logging.ERROR) + +Now do the actual traversal: + + _ = request.traverse('container/obj') +BrokenHook called +'__before_publishing_traverse__' call ... failed. +Traceback (most recent call last): +... +TypeError: BrokenHook + +Unregister the borken hook: + + _ = BeforeTraverse.unregisterBeforeTraverse(container, 'broken_hook') + +The list of 'before traverse' hooks is empty: + + container.__before_traverse__ +{} + +But the
[Zope-Checkins] SVN: Zope/branches/2.10/ - Fix #2155: Wrong parameters being passed to logger's error().
Log message for revision 69659: - Fix #2155: Wrong parameters being passed to logger's error(). Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/ZPublisher/BeforeTraverse.py A Zope/branches/2.10/lib/python/ZPublisher/tests/testBeforeTraverse.py -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2006-08-18 16:34:06 UTC (rev 69658) +++ Zope/branches/2.10/doc/CHANGES.txt 2006-08-18 16:46:42 UTC (rev 69659) @@ -8,6 +8,9 @@ Bugs Fixed + - Collector #2155: Fix wrong parameter being passed to +logger's error() method, with tests. + - Updated Five to stable 1.5 release. - Traversal order changes were causing WebDAV requests which used Modified: Zope/branches/2.10/lib/python/ZPublisher/BeforeTraverse.py === --- Zope/branches/2.10/lib/python/ZPublisher/BeforeTraverse.py 2006-08-18 16:34:06 UTC (rev 69658) +++ Zope/branches/2.10/lib/python/ZPublisher/BeforeTraverse.py 2006-08-18 16:46:42 UTC (rev 69659) @@ -16,7 +16,6 @@ from Acquisition import aq_base from logging import getLogger -import sys # Interface @@ -106,7 +105,7 @@ cob(container, request) except TypeError: LOG.error('%s call %s failed.' % ( -`self._hookname`, `cob`), exc_info=sys.exc_info()) +`self._hookname`, `cob`), exc_info=True) def add(self, cob): self._list.append(cob) @@ -151,6 +150,5 @@ # Only catch exceptions that are likely to be logic errors. # We shouldn't catch Redirects, Unauthorizeds, etc. since # the programmer may want to raise them deliberately. - LOG.error('BeforeTraverse: Error while invoking hook: %s' % self.name, - exc_info=sys.exc_info()) + exc_info=True) Copied: Zope/branches/2.10/lib/python/ZPublisher/tests/testBeforeTraverse.py (from rev 69658, Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py) === --- Zope/branches/2.9/lib/python/ZPublisher/tests/testBeforeTraverse.py 2006-08-18 16:34:06 UTC (rev 69658) +++ Zope/branches/2.10/lib/python/ZPublisher/tests/testBeforeTraverse.py 2006-08-18 16:46:42 UTC (rev 69659) @@ -0,0 +1,139 @@ +import sys +import logging + +from Acquisition import Implicit +from ZPublisher import BeforeTraverse +from ZPublisher.BaseRequest import BaseRequest +from ZPublisher.HTTPResponse import HTTPResponse + +def makeBaseRequest(root): +response = HTTPResponse() +environment = { 'URL': '', + 'PARENTS': [root], + 'steps': [], + '_hacked_path': 0, + '_test_counter': 0, + 'response': response } +return BaseRequest(environment) + + +class DummyObjectBasic(Implicit): + Dummy class with docstring. + +pass + + +class BrokenHook: + +def __call__(self, *args): + print self.__class__.__name__, 'called' + raise TypeError, self.__class__.__name__ + +def testBeforeTraverse(self): + +Zope supports a 'before traverse' hook that is used for several +features, including 'Site Access Rules'. It is implemented using a +special API for registering hooks, and the hooks themselves are +called during traversal by ZPublisher. + + root = DummyObjectBasic() + request = makeBaseRequest(root) + + container = DummyObjectBasic() + root.container = container + + obj = DummyObjectBasic() + container.obj = obj + +Setup a broken hook as the before traverse hook for the +container. That will create a 'MultiHook' object: + + BeforeTraverse.registerBeforeTraverse(container, BrokenHook(), +...'broken_hook') + + container.__before_publishing_traverse__ +ZPublisher.BeforeTraverse.MultiHook instance at ... + + container.__before_traverse__ +{(99, 'broken_hook'): ZPublisher.tests.testBeforeTraverse.BrokenHook ...} + +Setup logging so we can see the actual exception being logged: + + logger = logging.getLogger('ZPublisher') + level = logger.level + handlers = logger.handlers[:] + + logger.addHandler(logging.StreamHandler(sys.stdout)) + logger.setLevel(logging.ERROR) + +Now do the actual traversal: + + _ = request.traverse('container/obj') +BrokenHook called +'__before_publishing_traverse__' call ... failed. +Traceback (most recent call last): +... +TypeError: BrokenHook + +Unregister the borken hook: + + _ = BeforeTraverse.unregisterBeforeTraverse(container, 'broken_hook') + +The list of 'before traverse' hooks is empty: + + container.__before_traverse__ +{} + +But the 'MultiHook' is not
[Zope-Checkins] SVN: Products.Five/branches/1.4-layers/ adding test layer support
Log message for revision 69673: adding test layer support Changed: A Products.Five/branches/1.4-layers/ -=- Copied: Products.Five/branches/1.4-layers (from rev 69672, Products.Five/branches/1.4) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/1.4-layers/viewlet/tests.py adding comma
Log message for revision 69675: adding comma Changed: U Products.Five/branches/1.4-layers/viewlet/tests.py -=- Modified: Products.Five/branches/1.4-layers/viewlet/tests.py === --- Products.Five/branches/1.4-layers/viewlet/tests.py 2006-08-18 23:22:53 UTC (rev 69674) +++ Products.Five/branches/1.4-layers/viewlet/tests.py 2006-08-18 23:23:21 UTC (rev 69675) @@ -87,7 +87,7 @@ return unittest.TestSuite(( FunctionalDocFileSuite('README.txt'), FunctionalDocFileSuite('directives.txt', - package='Products.Five.viewlet' + package='Products.Five.viewlet', setUp=setUp, tearDown=tearDown ), )) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/1.4-layers/ adding layers, bumping version
Log message for revision 69676: adding layers, bumping version Changed: A Products.Five/branches/1.4-layers/tests/testing/layer.py U Products.Five/branches/1.4-layers/version.txt -=- Added: Products.Five/branches/1.4-layers/tests/testing/layer.py === --- Products.Five/branches/1.4-layers/tests/testing/layer.py2006-08-18 23:23:21 UTC (rev 69675) +++ Products.Five/branches/1.4-layers/tests/testing/layer.py2006-08-18 23:27:50 UTC (rev 69676) @@ -0,0 +1,20 @@ +from Testing.ZopeTestCase.utils import setDebugMode +from Testing.ZopeTestCase.layer import Zope2Layer + +class ZCMLLayer: +@classmethod +def setUp(cls): +# this keeps five from hiding config errors while toggle debug +# back on to let PTC perform efficiently +setDebugMode(1) +from Products.Five import zcml +zcml.load_site() +setDebugMode(0) + +@classmethod +def tearDown(cls): +from zope.testing.cleanup import cleanUp +cleanUp() + +class FiveLayer(ZCMLLayer, Zope2Layer): +3 + 2 Modified: Products.Five/branches/1.4-layers/version.txt === --- Products.Five/branches/1.4-layers/version.txt 2006-08-18 23:23:21 UTC (rev 69675) +++ Products.Five/branches/1.4-layers/version.txt 2006-08-18 23:27:50 UTC (rev 69676) @@ -1 +1 @@ -Five 1.4.1 +Five 1.4.1 (layers mod svn) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9-layer-support/ integrating layer support for tests in Testing.ZopeTestCase
Log message for revision 69677: integrating layer support for tests in Testing.ZopeTestCase Changed: A Zope/branches/2.9-layer-support/ -=- Copied: Zope/branches/2.9-layer-support (from rev 69676, Zope/branches/2.9) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9-layer-support/lib/python/Testing/ starting merge
Log message for revision 69678: starting merge Changed: A Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/layer.py A Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/tests.py A Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py A Zope/branches/2.9-layer-support/lib/python/Testing/tmp/ -=- Added: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/layer.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/layer.py 2006-08-19 00:59:19 UTC (rev 69677) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/layer.py 2006-08-19 02:33:50 UTC (rev 69678) @@ -0,0 +1,54 @@ +## +# +# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (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. +# +## + +layer support for ZopeTestCase + +$Id: $ + +import os +from utils import setDebugMode + +class ZopeLiteLayer: +@classmethod +def setUp(cls): +import ZopeLite + +@classmethod +def tearDown(cls): +raise NotImplementedError + +# products to install +_products=[] + +# setup functions +_z2_callables=[] +class Zope2Layer(ZopeLiteLayer): + stacks upon ZopeLiteLayer and handles products installs +@classmethod +def setUp(cls): +import ZopeLite as Zope2 +install = Zope2.installProduct + +[install(name, quiet=quiet) \ + for name, quiet in _products] + +[func(*args, **kw) for func, args, kw in _z2_callables] + +@classmethod +def tearDown(cls): +raise NotImplementedError + + +def installProduct(name, quiet=0): +if not (name, quiet) in _products: +_products.append((name, quiet)) Added: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/tests.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/tests.py 2006-08-19 00:59:19 UTC (rev 69677) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/tests.py 2006-08-19 02:33:50 UTC (rev 69678) @@ -0,0 +1,15 @@ +import os, sys +import unittest +suite = unittest.TestSuite() + +def test_suite(): +names = os.listdir(os.path.dirname(__file__)) +tests = [x for x in names \ + if x.startswith('test') and x.endswith('.py') and not x == 'tests.py'] + +for test in tests: +Testing = __import__(Testing.ZopeTestCase. + test[:-3]) +testmodule = getattr(Testing.ZopeTestCase, test[:-3]) +if hasattr(testmodule, 'test_suite'): +suite.addTest(testmodule.test_suite()) +return suite Added: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py 2006-08-19 00:59:19 UTC (rev 69677) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py 2006-08-19 02:33:50 UTC (rev 69678) @@ -0,0 +1,15 @@ +import os, sys +import unittest +suite = unittest.TestSuite() + +def test_suite(): +names = os.listdir(os.path.dirname(__file__)) +tests = [x for x in names \ + if x.startswith('test') and x.endswith('.py') and not x == 'tests.py'] + +for test in tests: +Testing = __import__(Testing.ZopeTestCase.zopedoctest. + test[:-3]) +testmodule = getattr(Testing.ZopeTestCase.zopedoctest, test[:-3]) +if hasattr(testmodule, 'test_suite'): +suite.addTest(testmodule.test_suite()) +return suite ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9-layer-support/lib/python/Testing/tmp/ removing tmp dir
Log message for revision 69680: removing tmp dir Changed: D Zope/branches/2.9-layer-support/lib/python/Testing/tmp/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ merging layers implementation
Log message for revision 69681: merging layers implementation Changed: U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/sandbox.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/__init__.py U Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py -=- Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py 2006-08-19 03:11:51 UTC (rev 69680) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeLite.py 2006-08-19 03:28:13 UTC (rev 69681) @@ -26,6 +26,7 @@ import os, sys, time +from utils import hasProduct, _print # Allow code to tell it is run by the test framework os.environ['ZOPETESTCASE'] = '1' @@ -36,11 +37,6 @@ # Shut up if we are not in control of the import process _quiet = sys.modules.has_key('Zope2') -def _print(msg): -'''Writes 'msg' to stderr and flushes the stream.''' -sys.stderr.write(msg) -sys.stderr.flush() - def _write(msg): '''Writes 'msg' to stderr if not _quiet.''' if not _quiet: @@ -139,10 +135,6 @@ _theApp = Zope2.app() _installedProducts = {} -def hasProduct(name): -'''Checks if a product can be found along Products.__path__''' -return name in [n[1] for n in get_products()] - def installProduct(name, quiet=0): '''Installs a Zope product.''' start = time.time() Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py 2006-08-19 03:11:51 UTC (rev 69680) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/ZopeTestCase.py 2006-08-19 03:28:13 UTC (rev 69681) @@ -29,6 +29,7 @@ import interfaces import utils import connections +import layer from AccessControl import getSecurityManager from AccessControl.SecurityManagement import newSecurityManager @@ -51,6 +52,8 @@ _setup_fixture = 1 +layer = layer.Zope2Layer + def _setup(self): '''Sets up the fixture. Framework authors may override. Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py 2006-08-19 03:11:51 UTC (rev 69680) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/__init__.py 2006-08-19 03:28:13 UTC (rev 69681) @@ -15,12 +15,12 @@ $Id$ -import ZopeLite as Zope2 import utils -from ZopeLite import hasProduct -from ZopeLite import installProduct -from ZopeLite import _print +from utils import hasProduct +from layer import installProduct +from utils import _print +from utils import setAllLayers from ZopeTestCase import folder_name from ZopeTestCase import user_name @@ -49,9 +49,10 @@ from zopedoctest import FunctionalDocTestSuite from zopedoctest import FunctionalDocFileSuite +from layer import ZopeLiteLayer +from layer import Zope2Layer + import zopedoctest as doctest import transaction import placeless -Zope = Zope2 - Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py 2006-08-19 03:11:51 UTC (rev 69680) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/base.py 2006-08-19 03:28:13 UTC (rev 69681) @@ -15,7 +15,6 @@ $Id$ -import ZopeLite as Zope2 import unittest import transaction import profiler @@ -25,10 +24,9 @@ from AccessControl.SecurityManagement import noSecurityManager - - def app(): '''Opens a ZODB connection and returns the app object.''' +import ZopeLite as Zope2 app = Zope2.app() app = utils.makerequest(app) connections.register(app) Modified: Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py === --- Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py 2006-08-19 03:11:51 UTC (rev 69680) +++ Zope/branches/2.9-layer-support/lib/python/Testing/ZopeTestCase/placeless.py 2006-08-19 03:28:13 UTC (rev 69681) @@ -44,9 +44,6 @@
[Zope-Checkins] SVN: Zope/branches/2.9-layer-support/lib/python/Products/ point five at 1.4-layers
Log message for revision 69682: point five at 1.4-layers Changed: _U Zope/branches/2.9-layer-support/lib/python/Products/ -=- Property changes on: Zope/branches/2.9-layer-support/lib/python/Products ___ Name: svn:externals - Five svn://svn.zope.org/repos/main/Products.Five/tags/1.3.7 + Five svn://svn.zope.org/repos/main/Products.Five/branches/1.4-layers ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins