[Zope-Checkins] SVN: Zope/branches Sorry, missspelled the branch.
Log message for revision 84556: Sorry, missspelled the branch. Changed: A Zope/branches/regebro-timezone-142148/ D Zope/branches-regebro-timezone-142148/ -=- Copied: Zope/branches/regebro-timezone-142148 (from rev 84555, Zope/branches-regebro-timezone-142148) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/ZPublisher/tests/testBeforeTraverse.py Whitespace fix.
Log message for revision 77280: Whitespace fix. Changed: U Zope/trunk/lib/python/ZPublisher/tests/testBeforeTraverse.py -=- Modified: Zope/trunk/lib/python/ZPublisher/tests/testBeforeTraverse.py === --- Zope/trunk/lib/python/ZPublisher/tests/testBeforeTraverse.py 2007-07-01 08:23:47 UTC (rev 77279) +++ Zope/trunk/lib/python/ZPublisher/tests/testBeforeTraverse.py 2007-07-01 13:23:27 UTC (rev 77280) @@ -9,11 +9,11 @@ def makeBaseRequest(root): response = HTTPResponse() environment = { 'URL': '', - 'PARENTS': [root], - 'steps': [], - '_hacked_path': 0, - '_test_counter': 0, - 'response': response } +'PARENTS': [root], +'steps': [], +'_hacked_path': 0, +'_test_counter': 0, +'response': response } return BaseRequest(environment) @@ -26,8 +26,8 @@ class BrokenHook: def __call__(self, *args): - print self.__class__.__name__, 'called' - raise TypeError, self.__class__.__name__ +print self.__class__.__name__, 'called' +raise TypeError, self.__class__.__name__ def testBeforeTraverse(self): ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/ Collector #2153: Supporting unquoted cookies with spaces.
Log message for revision 77281: Collector #2153: Supporting unquoted cookies with spaces. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/ZPublisher/HTTPRequest.py U Zope/trunk/lib/python/ZPublisher/tests/testHTTPRequest.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2007-07-01 13:23:27 UTC (rev 77280) +++ Zope/trunk/doc/CHANGES.txt 2007-07-01 13:32:18 UTC (rev 77281) @@ -102,6 +102,8 @@ Bugs Fixed + - Collector #2153: Supporting unquoted cookies with spaces. + - The REQUEST no longer accepts holds after it has been closed. - Five.browser.metaconfigure.page didn't protect names from interface Modified: Zope/trunk/lib/python/ZPublisher/HTTPRequest.py === --- Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 13:23:27 UTC (rev 77280) +++ Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 13:32:18 UTC (rev 77281) @@ -1476,7 +1476,7 @@ qparmre=re.compile( '([\x00- ]*([^\x00- ;,=]+)=([^]*)([\x00- ]*[;,])?[\x00- ]*)'), parmre=re.compile( -'([\x00- ]*([^\x00- ;,=]+)=([^\x00- ;,]*)([\x00- ]*[;,])?[\x00- ]*)'), +'([\x00- ]*([^\x00- ;,=]+)=([^;,]*)([\x00- ]*[;,])?[\x00- ]*)'), paramlessre=re.compile( '([\x00- ]*([^\x00- ;,=]+)[\x00- ]*[;,][\x00- ]*)'), Modified: Zope/trunk/lib/python/ZPublisher/tests/testHTTPRequest.py === --- Zope/trunk/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 13:23:27 UTC (rev 77280) +++ Zope/trunk/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 13:32:18 UTC (rev 77281) @@ -658,6 +658,20 @@ self.assertEquals(req.cookies['hmm'], '') self.assertEquals(req.cookies['baz'], 'gee') + # Unquoted multi-space cookies +env['HTTP_COOKIE'] = 'single=cookie data; ' \ +'quoted=cookie data with unquoted spaces; ' \ +'multi=cookie data with unquoted spaces; ' \ +'multi2=cookie data with unquoted spaces' +req = self._getHTTPRequest(env) +self.assertEquals(req.cookies['single'], 'cookie data') +self.assertEquals(req.cookies['quoted'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi2'], + 'cookie data with unquoted spaces') + TEST_ENVIRON = { 'CONTENT_TYPE': 'multipart/form-data; boundary=12345', 'REQUEST_METHOD': 'POST', ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/ Collector #2153: Supporting unquoted cookies with spaces.
Log message for revision 77282: Collector #2153: Supporting unquoted cookies with spaces. Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/2.9/lib/python/ZPublisher/tests/testHTTPRequest.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2007-07-01 13:32:18 UTC (rev 77281) +++ Zope/branches/2.9/doc/CHANGES.txt 2007-07-01 13:41:59 UTC (rev 77282) @@ -8,6 +8,8 @@ Bugs fixed + - Collector #2153: Supporting unquoted cookies with spaces. + - Collector #2295: Comments in PythonScripts could lead to syntax errors Modified: Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 13:32:18 UTC (rev 77281) +++ Zope/branches/2.9/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 13:41:59 UTC (rev 77282) @@ -1457,7 +1457,7 @@ qparmre=re.compile( '([\x00- ]*([^\x00- ;,=]+)=([^]*)([\x00- ]*[;,])?[\x00- ]*)'), parmre=re.compile( -'([\x00- ]*([^\x00- ;,=]+)=([^\x00- ;,]*)([\x00- ]*[;,])?[\x00- ]*)'), +'([\x00- ]*([^\x00- ;,=]+)=([^;,]*)([\x00- ]*[;,])?[\x00- ]*)'), paramlessre=re.compile( '([\x00- ]*([^\x00- ;,=]+)[\x00- ]*[;,][\x00- ]*)'), Modified: Zope/branches/2.9/lib/python/ZPublisher/tests/testHTTPRequest.py === --- Zope/branches/2.9/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 13:32:18 UTC (rev 77281) +++ Zope/branches/2.9/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 13:41:59 UTC (rev 77282) @@ -649,6 +649,20 @@ self.assertEquals(req.cookies['hmm'], '') self.assertEquals(req.cookies['baz'], 'gee') + # Unquoted multi-space cookies +env['HTTP_COOKIE'] = 'single=cookie data; ' \ +'quoted=cookie data with unquoted spaces; ' \ +'multi=cookie data with unquoted spaces; ' \ +'multi2=cookie data with unquoted spaces' +req = self._getHTTPRequest(env) +self.assertEquals(req.cookies['single'], 'cookie data') +self.assertEquals(req.cookies['quoted'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi2'], + 'cookie data with unquoted spaces') + TEST_ENVIRON = { 'CONTENT_TYPE': 'multipart/form-data; boundary=12345', 'REQUEST_METHOD': 'POST', ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/ Collector #2153: Supporting unquoted cookies with spaces.
Log message for revision 77283: Collector #2153: Supporting unquoted cookies with spaces. Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2007-07-01 13:41:59 UTC (rev 77282) +++ Zope/branches/2.10/doc/CHANGES.txt 2007-07-01 14:27:04 UTC (rev 77283) @@ -8,6 +8,8 @@ Bugs fixed + - Collector #2153: Supporting unquoted cookies with spaces. + - The REQUEST no longer accepts holds after it has been closed. - Collector #1441: WebDAV compatibility with Windows Web Folders Modified: Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 13:41:59 UTC (rev 77282) +++ Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py 2007-07-01 14:27:04 UTC (rev 77283) @@ -1471,7 +1471,7 @@ qparmre=re.compile( '([\x00- ]*([^\x00- ;,=]+)=([^]*)([\x00- ]*[;,])?[\x00- ]*)'), parmre=re.compile( -'([\x00- ]*([^\x00- ;,=]+)=([^\x00- ;,]*)([\x00- ]*[;,])?[\x00- ]*)'), +'([\x00- ]*([^\x00- ;,=]+)=([^;,]*)([\x00- ]*[;,])?[\x00- ]*)'), paramlessre=re.compile( '([\x00- ]*([^\x00- ;,=]+)[\x00- ]*[;,][\x00- ]*)'), Modified: Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py === --- Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 13:41:59 UTC (rev 77282) +++ Zope/branches/2.10/lib/python/ZPublisher/tests/testHTTPRequest.py 2007-07-01 14:27:04 UTC (rev 77283) @@ -649,6 +649,20 @@ self.assertEquals(req.cookies['hmm'], '') self.assertEquals(req.cookies['baz'], 'gee') + # Unquoted multi-space cookies +env['HTTP_COOKIE'] = 'single=cookie data; ' \ +'quoted=cookie data with unquoted spaces; ' \ +'multi=cookie data with unquoted spaces; ' \ +'multi2=cookie data with unquoted spaces' +req = self._getHTTPRequest(env) +self.assertEquals(req.cookies['single'], 'cookie data') +self.assertEquals(req.cookies['quoted'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi'], + 'cookie data with unquoted spaces') +self.assertEquals(req.cookies['multi2'], + 'cookie data with unquoted spaces') + TEST_ENVIRON = { 'CONTENT_TYPE': 'multipart/form-data; boundary=12345', 'REQUEST_METHOD': 'POST', ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/ Fix for collector #2261. At least an ugly temporary fix. This could be cleaned up a
Log message for revision 72040: Fix for collector #2261. At least an ugly temporary fix. This could be cleaned up a lot, but even better, we should take further steps towards using the z3 publisher. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/ZPublisher/BaseRequest.py U Zope/trunk/lib/python/webdav/tests/testPUT_factory.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2007-01-15 11:58:02 UTC (rev 72039) +++ Zope/trunk/doc/CHANGES.txt 2007-01-15 15:01:56 UTC (rev 72040) @@ -72,6 +72,7 @@ interfaces.py) Bugs Fixed + - Collector #2261: Acquisition when creating objects via Webdav. - Collector #2263: 'field2ulines' did not convert empty string correctly. Modified: Zope/trunk/lib/python/ZPublisher/BaseRequest.py === --- Zope/trunk/lib/python/ZPublisher/BaseRequest.py 2007-01-15 11:58:02 UTC (rev 72039) +++ Zope/trunk/lib/python/ZPublisher/BaseRequest.py 2007-01-15 15:01:56 UTC (rev 72040) @@ -427,6 +427,17 @@ # BrowserDefault returns the object to be published # (usually self) and a sequence of names to traverse to # find the method to be published. + +# This is webdav support. The last object in the path +# should not be acquired. Instead, a NullResource should +# be given if it doesn't exist: +if (no_acquire_flag and +hasattr(object, 'aq_base') and +not hasattr(object,'__bobo_traverse__')): +if object.aq_parent is not object.aq_inner.aq_parent: +from webdav.NullResource import NullResource +object = NullResource(parents[-2], object.getId(), self).__of__(parents[-2]) + if IBrowserPublisher.providedBy(object): adapter = object else: Modified: Zope/trunk/lib/python/webdav/tests/testPUT_factory.py === --- Zope/trunk/lib/python/webdav/tests/testPUT_factory.py 2007-01-15 11:58:02 UTC (rev 72039) +++ Zope/trunk/lib/python/webdav/tests/testPUT_factory.py 2007-01-15 15:01:56 UTC (rev 72040) @@ -80,7 +80,7 @@ put = request.traverse('/A/B/a') put(request, request.RESPONSE) # PUT should no acquire A.a -self.assertEqual(str(self.app.A.a), 'I am file a', 'PUT factory not should acquire content') +self.assertEqual(str(self.app.A.a), 'I am file a', 'PUT factory should not acquire content') # check for the newly created file self.assertEqual(str(self.app.A.B.a), 'bar') ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/trunk/ Fixed #2168: Missing import
Log message for revision 69765: Fixed #2168: Missing import Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/metaconfigure.py U Products.Five/trunk/tests/test_directives.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-08-24 14:26:52 UTC (rev 69764) +++ Products.Five/trunk/CHANGES.txt 2006-08-24 14:39:34 UTC (rev 69765) @@ -2,6 +2,11 @@ Five Changes +Five 1.5.1 (unreleased) += + +* Fixed #2168: Missing import + Five 1.5 (2006-08-13) = Modified: Products.Five/trunk/metaconfigure.py === --- Products.Five/trunk/metaconfigure.py2006-08-24 14:26:52 UTC (rev 69764) +++ Products.Five/trunk/metaconfigure.py2006-08-24 14:39:34 UTC (rev 69765) @@ -15,6 +15,7 @@ $Id$ +import warnings from zope.configuration.exceptions import ConfigurationError from zope.app.component import contentdirective from Products.Five.security import protectName, initializeClass Modified: Products.Five/trunk/tests/test_directives.py === --- Products.Five/trunk/tests/test_directives.py2006-08-24 14:26:52 UTC (rev 69764) +++ Products.Five/trunk/tests/test_directives.py2006-08-24 14:39:34 UTC (rev 69765) @@ -73,6 +73,51 @@ cleanUp() +def test_content_deprecation(): + +Test deprecated content directive + +There was a bug in the content directive deprecation code +which caused all code that use this directive break. +So we test this to make sure it works. If the content +directive will have been removed, this test can be removed +entirely as well. + +First, we load the configuration file: + + import Products.Five.tests + from Products.Five import zcml + zcml.load_config('meta.zcml', Products.Five) + zcml.load_config('directives.zcml', Products.Five.tests) + +Use the content directives: this gives a deprecation +warning but should otherwise be all right. (We embed the block +to suppress the deprecation warning...) + + import warnings + warnings.showwarning, _savewarning = lambda *args, **kw: None, warnings.showwarning + zcml.load_string(''' + ... configure xmlns=http://namespaces.zope.org/zope; + ... content class=Products.Five.tests.classes.One + ... implements interface=Products.Five.tests.classes.IOne / + ... /content + ... /configure + ... ''') + +Check that they are all right. + + from Products.Five.tests.classes import One, Two, IOne, ITwo + IOne.implementedBy(One) + True + +Clean up adapter registry and others: + + warnings.showwarning = _savewarning + from zope.testing.cleanup import cleanUp + cleanUp() + + + def test_suite(): from Testing.ZopeTestCase import ZopeDocTestSuite return ZopeDocTestSuite() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/trunk/ Support and tests for site migration from Five.site to Five.component.
Log message for revision 69269: Support and tests for site migration from Five.site to Five.component. Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/doc/localsite.txt U Products.Five/trunk/site/browser.py U Products.Five/trunk/site/managesite.pt U Products.Five/trunk/site/tests/test_localsite.py U Products.Five/trunk/site/tests/test_utility.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-07-27 10:03:20 UTC (rev 69268) +++ Products.Five/trunk/CHANGES.txt 2006-07-27 12:33:37 UTC (rev 69269) @@ -24,7 +24,8 @@ (and not on attributes). * The FiveSiteManager classes now work again, but are deprecated for the - new zope.component support. + new zope.component support. There is also a method to migrate Five.site + to zope.component. Five 1.5c (2006-05-29) == Modified: Products.Five/trunk/doc/localsite.txt === --- Products.Five/trunk/doc/localsite.txt 2006-07-27 10:03:20 UTC (rev 69268) +++ Products.Five/trunk/doc/localsite.txt 2006-07-27 12:33:37 UTC (rev 69269) @@ -42,8 +42,15 @@ or programmatically through enableLocalSiteHook(site) turn it into a site. The new setup involves calling enableSite(site) and createing and setting -a site manager. The simplest way to do this programatically is to look -up the components.html view on the site, and calling view.makeSite(). +a site manager. The simplest way to do this manually is to go to the +components.html view of the object you want to make a site, and press the +Make site button. The easist way to do this programmatically, is to look +up the components.html view on the site, and calling view.makeSite(): + +components_view = queryMultiAdapter((self.context, self.request), + Interface, 'components.html') +components_view.makeSite() + As any ObjectManager can be a site there is no longer any need to specially mark the class as being a possible site. @@ -62,7 +69,9 @@ Migrating the actual sites .. -Not Yet Implemented. +Go to the object of the site, and add manage_site.html to the URL to open +the old site management view. There you have a button +Migrate to Five.component. Press it to migrate the site. Experimental forwards compatibility ... @@ -76,7 +85,7 @@ Old site implementation details +=== The rest of this document documents the details of the old site implementation. Everything from here on concerns only the old implementation and is of mainly Modified: Products.Five/trunk/site/browser.py === --- Products.Five/trunk/site/browser.py 2006-07-27 10:03:20 UTC (rev 69268) +++ Products.Five/trunk/site/browser.py 2006-07-27 12:33:37 UTC (rev 69269) @@ -16,7 +16,9 @@ $Id$ from zope.app.component.interfaces import ISite -from zope.app.component.hooks import clearSite +from zope.app.component.hooks import clearSite, setSite +from zope.component import getSiteManager, queryMultiAdapter +from zope.interface import Interface, providedBy from Products.Five.browser import BrowserView from Products.Five.site.localsite import enableLocalSiteHook, disableLocalSiteHook @@ -31,10 +33,16 @@ self.makeSite() elif form.has_key('UPDATE_UNMAKESITE'): self.unmakeSite() +elif form.has_key('UPDATE_MIGRATE'): +self.migrateToFive15() def isSite(self): return ISite.providedBy(self.context) +def isOldSite(self): +from Products.Five.site.interfaces import IFiveSiteManager +return self.isSite() and IFiveSiteManager.providedBy(getSiteManager()) + def makeSite(self): Convert a possible site to a site if self.isSite(): @@ -58,3 +66,30 @@ clearSite() return This object is no longer a site + +def migrateToFive15(self): +all_utilities = self.context.utilities.objectItems() + +self.unmakeSite() +self.context.manage_delObjects(['utilities']) +components_view = queryMultiAdapter((self.context, self.request), +Interface, 'components.html') +components_view.makeSite() +setSite(self.context) + +site_manager = getSiteManager() +for id, utility in all_utilities: +info = id.split('-') +if len(info) == 1: +name = '' +else: +name = info[1] +interface_name = info[0] + +for iface in providedBy(utility): +if iface.getName() == interface_name: +site_manager.registerUtility(utility, iface, name=name) + +
[Zope-Checkins] SVN: Products.Five/trunk/ Now you can use the old registry with the new API for registerig components.
Log message for revision 69271: Now you can use the old registry with the new API for registerig components. BBB support shold be pretty much complete. Changed: U Products.Five/trunk/doc/localsite.txt U Products.Five/trunk/site/localsite.py U Products.Five/trunk/site/tests/test_utility.py -=- Modified: Products.Five/trunk/doc/localsite.txt === --- Products.Five/trunk/doc/localsite.txt 2006-07-27 13:51:25 UTC (rev 69270) +++ Products.Five/trunk/doc/localsite.txt 2006-07-27 14:15:46 UTC (rev 69271) @@ -89,10 +89,8 @@ The rest of this document documents the details of the old site implementation. Everything from here on concerns only the old implementation and is of mainly -hysterical interest: +hysterical interest. - - By default, Zope 3 has a global site which is configured through ZCML. It provides the fallback for all component look-up. Local sites are typically set during traversal, when the traverser encounters an Modified: Products.Five/trunk/site/localsite.py === --- Products.Five/trunk/site/localsite.py 2006-07-27 13:51:25 UTC (rev 69270) +++ Products.Five/trunk/site/localsite.py 2006-07-27 14:15:46 UTC (rev 69271) @@ -16,12 +16,26 @@ $Id$ from zope.interface import implements +from zope.interface.interface import InterfaceClass from zope.component import getGlobalSiteManager from zope.component.interfaces import ComponentLookupError from zope.app.component.interfaces import ISite, IPossibleSite from Acquisition import aq_parent, aq_inner from Products.Five.site.interfaces import IFiveSiteManager, IFiveUtilityRegistry +from operator import xor +def one_of_three(a, b, c): +# Logical table for a three part test where only one can be true: +# 0 0 0: 0 +# 0 0 1: 1 +# 0 1 0: 1 +# 0 1 1: 0 +# 1 0 0: 1 +# 1 0 1: 0 +# 1 1 0: 0 +# 1 1 1: 0 +return xor(xor(a, b), c) and not (a and b and c) + class FiveSiteManager(object): implements(IFiveSiteManager) @@ -89,7 +103,56 @@ def getAllUtilitiesRegisteredFor(self, interface): return self.utilities.getAllUtilitiesRegisteredFor(interface) -def registerUtility(self, interface, utility, name=''): +def registerUtility(self, *args, **kw): +# Can be called with new API: +# component, provided=None, name=u'', info=u'', event=True +# where info and event are ignored, or old api: +# interface, utility, name='' +name = kw.get('name', u'') +interface_kw = kw.get('interface', None) +provided_kw = kw.get('provided', None) +utility_kw = kw.get('utility', None) +component_kw = kw.get('component', None) + +interface = None +utility = None +if len(args) 0: +# Positional argument 1 +if isinstance(args[0], InterfaceClass): +interface = args[0] +else: +utility = args[0] + +if len(args) 1: +if isinstance(args[1], InterfaceClass): +interface = args[1] +else: +utility = args[1] + +if len(args) 2: +if name: +raise TypeError(You can only provide one name) +else: +name = args[2] + +if not one_of_three(interface is not None, +interface_kw is not None, +provided_kw is not None): +raise TypeError(You can specify one and only one interface) +if interface is None: +interface = interface_kw +if interface is None: +interface = provided_kw + +if not one_of_three(utility is not None, +utility_kw is not None, +component_kw is not None): +raise TypeError(You can specify one and only one interface) +if utility is None: +utility = utility_kw +if utility is None: +utility = component_kw + return self.utilities.registerUtility(interface, utility, name) class FiveSite: @@ -121,9 +184,8 @@ def disableLocalSiteHook(obj): Remove __before_traverse__ hook for Local Site -warnings.warn(The disableLocalSiteHook is deprecated and will be removed - in Zope 2.12. \nSee Five/doc/localsite.txt ., - DeprecationWarning, 2) +# This method is of course deprecated too, but issuing a warning is +# silly. disableSite(obj) clearSite() obj.setSiteManager(None) Modified: Products.Five/trunk/site/tests/test_utility.py === --- Products.Five/trunk/site/tests/test_utility.py 2006-07-27 13:51:25 UTC (rev 69270) +++
[Zope-Checkins] SVN: Products.Five/trunk/ The FiveSiteManager classes now work again, but are deprecated for the
Log message for revision 69259: The FiveSiteManager classes now work again, but are deprecated for the new zope.component support. Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/doc/localsite.txt U Products.Five/trunk/site/browser.py U Products.Five/trunk/site/localsite.py U Products.Five/trunk/site/metaconfigure.py U Products.Five/trunk/site/tests/functional.txt U Products.Five/trunk/site/tests/sitemanager.txt U Products.Five/trunk/site/tests/test_localsite.py U Products.Five/trunk/site/tests/test_utility.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-07-25 17:58:06 UTC (rev 69258) +++ Products.Five/trunk/CHANGES.txt 2006-07-25 18:17:23 UTC (rev 69259) @@ -23,6 +23,9 @@ * Changed the tests to reflect that defaultView no only works for views (and not on attributes). +* The FiveSiteManager classes now work again, but are deprecated for the + new zope.component support. + Five 1.5c (2006-05-29) == Modified: Products.Five/trunk/doc/localsite.txt === --- Products.Five/trunk/doc/localsite.txt 2006-07-25 17:58:06 UTC (rev 69258) +++ Products.Five/trunk/doc/localsite.txt 2006-07-25 18:17:23 UTC (rev 69259) @@ -9,6 +9,81 @@ their configuration be persisted in the ZODB as well as managed through the web interface. + +Five 1.5 supports two distinct and slightly incompatible versions of +local site support. The first one, (here known as old sites) was +introduced in Five 1.3 and is based on Zope 3.2s site implementation. +But the site implementation in Zope 3.2 was overly complicated, and +for 3.3 it was refactored, and Five 1.5 contains support for this new +local site support as well (known as new sites). + +For documentation of how to use local sites, see the Zope 3.3 documentation. +This document is mostly about how the implementation of the old sites work, +and how to migrate from Five 1.3 and 1.4. + + +Migration from old sites to new sites +- + +New sites are based on Zope 3.3s new site managers and persistent +component registries. Old sites are based on specific Five implementation +of site managers, and keeps utilities in a folder called utilities. + +They are used basically the same, but they are created differently, +and also, when you look up a utility with getUtility or queryUtility, in +old sites, the utility will have an acquicition context, while in the new +sites it will not. + +Setting up the site +... + +The old setup of a site was done by marking the class of the site as a +possible site with five:localsite, and then either manually through the ZMI +or programmatically through enableLocalSiteHook(site) turn it into a site. + +The new setup involves calling enableSite(site) and createing and setting +a site manager. The simplest way to do this programatically is to look +up the components.html view on the site, and calling view.makeSite(). +As any ObjectManager can be a site there is no longer any need to specially +mark the class as being a possible site. + +Registering local utilities +... + +The old usage was to get the site manager, either throgh adapting with +IFiveUtilityRegistry(site) or by calling getSiteManager(). You could then +register the utilities with sitemanager.registerUtility(interface, utility) + +The new way is to call getSiteManager().registerUtility(object, provided). +Note that in the old way, the first parameter is the interface name, and +the second the actual utility object, but in the new way, it is the other +way around. + +Migrating the actual sites +.. + +Not Yet Implemented. + +Experimental forwards compatibility +... + +If you have software using the old sites, and software using the new sites, +there is sligthly experimental support to make software expecting new sites +to work with old sites. Nothing is promised with this, as it is largely +untested. The best thing to do is without a doubt to convert your old site +software and your old sites to use new sites. + + + +Old site implementation details +--- + +The rest of this document documents the details of the old site implementation. +Everything from here on concerns only the old implementation and is of mainly +hysterical interest: + + + By default, Zope 3 has a global site which is configured through ZCML. It provides the fallback for all component look-up. Local sites are typically set during traversal, when the traverser encounters an Modified: Products.Five/trunk/site/browser.py === --- Products.Five/trunk/site/browser.py 2006-07-25 17:58:06 UTC (rev 69258) +++
[Zope-Checkins] SVN: Zope/branches/regebro-traversalfix/ View and attribute lookup order was changed to the following:
Log message for revision 68655: View and attribute lookup order was changed to the following: 1. Unacquired attributes 2. Views 3. Acquired attributes According to consensus in z3-five mailing list: http://codespeak.net/pipermail/z3-five/2006q2/001474.html Changed: U Zope/branches/regebro-traversalfix/doc/CHANGES.txt U Zope/branches/regebro-traversalfix/lib/python/OFS/Traversable.py U Zope/branches/regebro-traversalfix/lib/python/OFS/tests/testTraverse.py U Zope/branches/regebro-traversalfix/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/regebro-traversalfix/doc/CHANGES.txt === --- Zope/branches/regebro-traversalfix/doc/CHANGES.txt 2006-06-15 14:47:15 UTC (rev 68654) +++ Zope/branches/regebro-traversalfix/doc/CHANGES.txt 2006-06-15 15:18:40 UTC (rev 68655) @@ -33,4 +33,10 @@ - Collector #2063: cleaned up some mess in MailHost.sendTemplate() - + - View and attribute lookup order was changed to the following: + 1. Unacquired attributes + 2. Views + 3. Acquired attributes +According to consensus in z3-five mailing list: +http://codespeak.net/pipermail/z3-five/2006q2/001474.html + Modified: Zope/branches/regebro-traversalfix/lib/python/OFS/Traversable.py === --- Zope/branches/regebro-traversalfix/lib/python/OFS/Traversable.py 2006-06-15 14:47:15 UTC (rev 68654) +++ Zope/branches/regebro-traversalfix/lib/python/OFS/Traversable.py 2006-06-15 15:18:40 UTC (rev 68655) @@ -190,76 +190,93 @@ continue bobo_traverse = _getattr(obj, '__bobo_traverse__', _none) -if name and name[:1] in '@+': -# Process URI segment parameters. -ns, nm = nsParse(name) -if ns: -try: -next = namespaceLookup(ns, nm, obj, - self.REQUEST).__of__(obj) -if restricted and not securityManager.validate( -obj, obj, name, next): +try: +if name and name[:1] in '@+': +# Process URI segment parameters. +ns, nm = nsParse(name) +if ns: +try: +next = namespaceLookup(ns, nm, obj, + self.REQUEST).__of__(obj) +if restricted and not securityManager.validate( +obj, obj, name, next): +raise Unauthorized, name +except TraversalError: +raise AttributeError(name) +elif bobo_traverse is not _none: +next = bobo_traverse(REQUEST, name) +if restricted: +if aq_base(next) is not next: +# The object is wrapped, so the acquisition +# context is the container. +container = aq_parent(aq_inner(next)) +elif _getattr(next, 'im_self', _none) is not _none: +# Bound method, the bound instance +# is the container +container = next.im_self +elif _getattr(aq_base(obj), name, marker) == next: +# Unwrapped direct attribute of the object so +# object is the container +container = obj +else: +# Can't determine container +container = _none +try: +validated = securityManager.validate( + obj, container, name, next) +except Unauthorized: +# If next is a simple unwrapped property, it's +# parentage is indeterminate, but it may have been +# acquired safely. In this case validate will +# raise an error, and we can explicitly check that +# our value was acquired safely. +validated = 0 +if container is _none and \ + guarded_getattr(obj, name, marker) is next: +validated = 1 +if not
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversalfix/traversable.py BBB fix.
Log message for revision 68747: BBB fix. Changed: U Products.Five/branches/regebro-traversalfix/traversable.py -=- Modified: Products.Five/branches/regebro-traversalfix/traversable.py === --- Products.Five/branches/regebro-traversalfix/traversable.py 2006-06-19 06:56:11 UTC (rev 68746) +++ Products.Five/branches/regebro-traversalfix/traversable.py 2006-06-19 11:12:18 UTC (rev 68747) @@ -22,8 +22,8 @@ __bobo_traverse__ and ITraverser/ITraversable for controlling URL traversal have become obsolete. Use an IPublishTraverse adapter instead. This reference will go away in Zope 2.12., -Traversable = Products.Five.bbb.Traversable, -FiveTraversable = zope.traversing.adapters.DefaultTraversable, +Traversable = Products.Five.bbb:Traversable, +FiveTraversable = zope.traversing.adapters:DefaultTraversable, ) zope.deferredimport.deprecated( Use zope.publisher.browser.TestRequest instead., ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversalfix/ * Added tests to make sure that views are not blocked by acquired attributes.
Log message for revision 68748: * Added tests to make sure that views are not blocked by acquired attributes. * Changed the tests to reflect that defaultView no only works for views (and not on attributes). Changed: U Products.Five/branches/regebro-traversalfix/CHANGES.txt U Products.Five/branches/regebro-traversalfix/browser/tests/test_defaultview.py -=- Modified: Products.Five/branches/regebro-traversalfix/CHANGES.txt === --- Products.Five/branches/regebro-traversalfix/CHANGES.txt 2006-06-19 11:12:18 UTC (rev 68747) +++ Products.Five/branches/regebro-traversalfix/CHANGES.txt 2006-06-19 11:19:30 UTC (rev 68748) @@ -8,7 +8,12 @@ * Added Five.browser.pagetemplatefile.ViewPageTemplateFile as an alias to ZopeTwoPageTemplateFile and as a Zope 2 correspondence to zope.app.pagetemplate.ViewPageTemplateFile. + +* Added tests to make sure that views are not blocked by acquired attributes. +* Changed the tests to reflect that defaultView no only works for views + (and not on attributes). + Five 1.5c (2006-05-29) == Modified: Products.Five/branches/regebro-traversalfix/browser/tests/test_defaultview.py === --- Products.Five/branches/regebro-traversalfix/browser/tests/test_defaultview.py 2006-06-19 11:12:18 UTC (rev 68747) +++ Products.Five/branches/regebro-traversalfix/browser/tests/test_defaultview.py 2006-06-19 11:19:30 UTC (rev 68748) @@ -88,15 +88,14 @@ ... The mouse has been eaten by the eagle -This tests whether an existing ``index_html`` method is still -supported and called: - +In Five 1.5 ``index_html`` you can no longer set default views to anything +else than views: + print http(r''' ... GET /test_folder_1_/testindex HTTP/1.1 ... ''') - HTTP/1.1 200 OK + HTTP/1.1 404 Not Found ... - Default index_html called Disabled __call__ overriding for now. Causes more trouble than it fixes. Thus, no test here: ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-traversalfix/doc/CHANGES.txt The defaultView directive now only looks up views, not attributes.
Log message for revision 68749: The defaultView directive now only looks up views, not attributes. Changed: U Zope/branches/regebro-traversalfix/doc/CHANGES.txt -=- Modified: Zope/branches/regebro-traversalfix/doc/CHANGES.txt === --- Zope/branches/regebro-traversalfix/doc/CHANGES.txt 2006-06-19 11:19:30 UTC (rev 68748) +++ Zope/branches/regebro-traversalfix/doc/CHANGES.txt 2006-06-19 11:26:07 UTC (rev 68749) @@ -40,3 +40,5 @@ According to consensus in z3-five mailing list: http://codespeak.net/pipermail/z3-five/2006q2/001474.html + - The defaultView directive now only looks up views, not attributes. + \ No newline at end of file ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/ZPublisher/HTTPRequest.py Spaceified some tabs.
Log message for revision 68751: Spaceified some tabs. Changed: U Zope/trunk/lib/python/ZPublisher/HTTPRequest.py -=- Modified: Zope/trunk/lib/python/ZPublisher/HTTPRequest.py === --- Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2006-06-19 14:35:22 UTC (rev 68750) +++ Zope/trunk/lib/python/ZPublisher/HTTPRequest.py 2006-06-19 14:51:45 UTC (rev 68751) @@ -1498,11 +1498,11 @@ else: # Broken Cookie without = nor value. - broken_p = paramlessre.match(text) - if broken_p: - l = len(broken_p.group(1)) - name = broken_p.group(2) - value = '' +broken_p = paramlessre.match(text) +if broken_p: +l = len(broken_p.group(1)) +name = broken_p.group(2) +value = '' else: return result ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/trunk/ * Added tests to make sure that views are not blocked by acquired attributes.
Log message for revision 68752: * Added tests to make sure that views are not blocked by acquired attributes. * Changed the tests to reflect that defaultView no only works for views (and not on attributes). Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/browser/tests/test_defaultview.py U Products.Five/trunk/browser/tests/test_traversable.py U Products.Five/trunk/traversable.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-06-19 14:51:45 UTC (rev 68751) +++ Products.Five/trunk/CHANGES.txt 2006-06-19 15:02:21 UTC (rev 68752) @@ -17,7 +17,12 @@ * Added Five.browser.pagetemplatefile.ViewPageTemplateFile as an alias to ZopeTwoPageTemplateFile and as a Zope 2 correspondence to zope.app.pagetemplate.ViewPageTemplateFile. + +* Added tests to make sure that views are not blocked by acquired attributes. +* Changed the tests to reflect that defaultView no only works for views + (and not on attributes). + Five 1.5c (2006-05-29) == Modified: Products.Five/trunk/browser/tests/test_defaultview.py === --- Products.Five/trunk/browser/tests/test_defaultview.py 2006-06-19 14:51:45 UTC (rev 68751) +++ Products.Five/trunk/browser/tests/test_defaultview.py 2006-06-19 15:02:21 UTC (rev 68752) @@ -88,15 +88,14 @@ ... The mouse has been eaten by the eagle -This tests whether an existing ``index_html`` method is still -supported and called: - +In Five 1.5 ``index_html`` you can no longer set default views to anything +else than views: + print http(r''' ... GET /test_folder_1_/testindex HTTP/1.1 ... ''') - HTTP/1.1 200 OK + HTTP/1.1 404 Not Found ... - Default index_html called Disabled __call__ overriding for now. Causes more trouble than it fixes. Thus, no test here: Modified: Products.Five/trunk/browser/tests/test_traversable.py === --- Products.Five/trunk/browser/tests/test_traversable.py 2006-06-19 14:51:45 UTC (rev 68751) +++ Products.Five/trunk/browser/tests/test_traversable.py 2006-06-19 15:02:21 UTC (rev 68752) @@ -206,6 +206,13 @@ ... attribute=eagle ... permission=zope2.Public ... / + ... browser:page + ... name=mouse + ... for=OFS.interfaces.IObjectManager + ... class=Products.Five.browser.tests.pages.SimpleView + ... attribute=mouse + ... permission=zope2.Public + ... / ... /configure''' import Products.Five from Products.Five import zcml @@ -262,6 +269,17 @@ ... The eagle has landed +However, acquired attributes *should* be shadowed. See discussion on +http://codespeak.net/pipermail/z3-five/2006q2/001474.html + + manage_addIndexSimpleContent(self.folder, 'mouse', 'Mouse') + print http(r''' + ... GET /test_folder_1_/ftf/mouse HTTP/1.1 + ... ''') + HTTP/1.1 200 OK + ... + The mouse has been eaten by the eagle + Clean up: from zope.app.testing.placelesssetup import tearDown Modified: Products.Five/trunk/traversable.py === --- Products.Five/trunk/traversable.py 2006-06-19 14:51:45 UTC (rev 68751) +++ Products.Five/trunk/traversable.py 2006-06-19 15:02:21 UTC (rev 68752) @@ -22,8 +22,8 @@ __bobo_traverse__ and ITraverser/ITraversable for controlling URL traversal have become obsolete. Use an IPublishTraverse adapter instead. This reference will go away in Zope 2.12., -Traversable = Products.Five.bbb.Traversable, -FiveTraversable = zope.traversing.adapters.DefaultTraversable, +Traversable = Products.Five.bbb:Traversable, +FiveTraversable = zope.traversing.adapters:DefaultTraversable, ) zope.deferredimport.deprecated( Use zope.publisher.browser.TestRequest instead., ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/ - View and attribute lookup order was changed to the following:
Log message for revision 68753: - View and attribute lookup order was changed to the following: 1. Unacquired attributes 2. Views 3. Acquired attributes According to consensus in z3-five mailing list: http://codespeak.net/pipermail/z3-five/2006q2/001474.html - The defaultView directive now only looks up views, not attributes. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/OFS/Traversable.py U Zope/trunk/lib/python/OFS/tests/testTraverse.py U Zope/trunk/lib/python/ZPublisher/BaseRequest.py U Zope/trunk/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2006-06-19 15:02:21 UTC (rev 68752) +++ Zope/trunk/doc/CHANGES.txt 2006-06-19 15:03:17 UTC (rev 68753) @@ -33,4 +33,12 @@ - Collector #2063: cleaned up some mess in MailHost.sendTemplate() - + - View and attribute lookup order was changed to the following: + 1. Unacquired attributes + 2. Views + 3. Acquired attributes +According to consensus in z3-five mailing list: +http://codespeak.net/pipermail/z3-five/2006q2/001474.html + + - The defaultView directive now only looks up views, not attributes. + \ No newline at end of file Modified: Zope/trunk/lib/python/OFS/Traversable.py === --- Zope/trunk/lib/python/OFS/Traversable.py2006-06-19 15:02:21 UTC (rev 68752) +++ Zope/trunk/lib/python/OFS/Traversable.py2006-06-19 15:03:17 UTC (rev 68753) @@ -190,76 +190,93 @@ continue bobo_traverse = _getattr(obj, '__bobo_traverse__', _none) -if name and name[:1] in '@+': -# Process URI segment parameters. -ns, nm = nsParse(name) -if ns: -try: -next = namespaceLookup(ns, nm, obj, - self.REQUEST).__of__(obj) -if restricted and not securityManager.validate( -obj, obj, name, next): +try: +if name and name[:1] in '@+': +# Process URI segment parameters. +ns, nm = nsParse(name) +if ns: +try: +next = namespaceLookup(ns, nm, obj, + self.REQUEST).__of__(obj) +if restricted and not securityManager.validate( +obj, obj, name, next): +raise Unauthorized, name +except TraversalError: +raise AttributeError(name) +elif bobo_traverse is not _none: +next = bobo_traverse(REQUEST, name) +if restricted: +if aq_base(next) is not next: +# The object is wrapped, so the acquisition +# context is the container. +container = aq_parent(aq_inner(next)) +elif _getattr(next, 'im_self', _none) is not _none: +# Bound method, the bound instance +# is the container +container = next.im_self +elif _getattr(aq_base(obj), name, marker) == next: +# Unwrapped direct attribute of the object so +# object is the container +container = obj +else: +# Can't determine container +container = _none +try: +validated = securityManager.validate( + obj, container, name, next) +except Unauthorized: +# If next is a simple unwrapped property, it's +# parentage is indeterminate, but it may have been +# acquired safely. In this case validate will +# raise an error, and we can explicitly check that +# our value was acquired safely. +validated = 0 +if container is _none and \ + guarded_getattr(obj, name, marker) is next: +
[Zope-Checkins] SVN: Zope/branches/regebro-traversalfix/lib/python/ZPublisher/HTTPRequest.py Removed some tabs.
Log message for revision 68649: Removed some tabs. Changed: U Zope/branches/regebro-traversalfix/lib/python/ZPublisher/HTTPRequest.py -=- Modified: Zope/branches/regebro-traversalfix/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/regebro-traversalfix/lib/python/ZPublisher/HTTPRequest.py 2006-06-15 11:22:56 UTC (rev 68648) +++ Zope/branches/regebro-traversalfix/lib/python/ZPublisher/HTTPRequest.py 2006-06-15 11:25:08 UTC (rev 68649) @@ -1498,11 +1498,11 @@ else: # Broken Cookie without = nor value. - broken_p = paramlessre.match(text) - if broken_p: - l = len(broken_p.group(1)) - name = broken_p.group(2) - value = '' +broken_p = paramlessre.match(text) +if broken_p: +l = len(broken_p.group(1)) +name = broken_p.group(2) +value = '' else: return result ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/ Merge from regebro-traversalfix branch:
Log message for revision 68776: Merge from regebro-traversalfix branch: - View and attribute lookup order was changed to the following: 1. Unacquired attributes 2. Views 3. Acquired attributes According to consensus in z3-five mailing list: http://codespeak.net/pipermail/z3-five/2006q2/001474.html - The defaultView directive now only looks up views, not attributes. Changed: U Zope/branches/2.10/doc/CHANGES.txt U Zope/branches/2.10/lib/python/OFS/Traversable.py U Zope/branches/2.10/lib/python/OFS/tests/testTraverse.py _U Zope/branches/2.10/lib/python/Products/ U Zope/branches/2.10/lib/python/ZPublisher/BaseRequest.py U Zope/branches/2.10/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/2.10/lib/python/ZPublisher/tests/testBaseRequest.py -=- Modified: Zope/branches/2.10/doc/CHANGES.txt === --- Zope/branches/2.10/doc/CHANGES.txt 2006-06-20 15:58:06 UTC (rev 68775) +++ Zope/branches/2.10/doc/CHANGES.txt 2006-06-21 11:26:57 UTC (rev 68776) @@ -38,6 +38,15 @@ - Collector #2063: cleaned up some mess in MailHost.sendTemplate() + - View and attribute lookup order was changed to the following: + 1. Unacquired attributes + 2. Views + 3. Acquired attributes +According to consensus in z3-five mailing list: +http://codespeak.net/pipermail/z3-five/2006q2/001474.html + + - The defaultView directive now only looks up views, not attributes. + Zope 2.10.0 beta 1 (2006/05/30) Restructuring Modified: Zope/branches/2.10/lib/python/OFS/Traversable.py === --- Zope/branches/2.10/lib/python/OFS/Traversable.py2006-06-20 15:58:06 UTC (rev 68775) +++ Zope/branches/2.10/lib/python/OFS/Traversable.py2006-06-21 11:26:57 UTC (rev 68776) @@ -190,76 +190,93 @@ continue bobo_traverse = _getattr(obj, '__bobo_traverse__', _none) -if name and name[:1] in '@+': -# Process URI segment parameters. -ns, nm = nsParse(name) -if ns: -try: -next = namespaceLookup(ns, nm, obj, - self.REQUEST).__of__(obj) -if restricted and not securityManager.validate( -obj, obj, name, next): +try: +if name and name[:1] in '@+': +# Process URI segment parameters. +ns, nm = nsParse(name) +if ns: +try: +next = namespaceLookup(ns, nm, obj, + self.REQUEST).__of__(obj) +if restricted and not securityManager.validate( +obj, obj, name, next): +raise Unauthorized, name +except TraversalError: +raise AttributeError(name) +elif bobo_traverse is not _none: +next = bobo_traverse(REQUEST, name) +if restricted: +if aq_base(next) is not next: +# The object is wrapped, so the acquisition +# context is the container. +container = aq_parent(aq_inner(next)) +elif _getattr(next, 'im_self', _none) is not _none: +# Bound method, the bound instance +# is the container +container = next.im_self +elif _getattr(aq_base(obj), name, marker) == next: +# Unwrapped direct attribute of the object so +# object is the container +container = obj +else: +# Can't determine container +container = _none +try: +validated = securityManager.validate( + obj, container, name, next) +except Unauthorized: +# If next is a simple unwrapped property, it's +# parentage is indeterminate, but it may have been +# acquired safely. In this case validate will +# raise an error, and we can explicitly check that +# our value was acquired safely. +
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_refactor/ Removed dead branch.
Log message for revision 67833: Removed dead branch. Changed: D Zope/branches/regebro-wsgi_refactor/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-issue_1888/ Pruning some branches. This was merged a long time ago.
Log message for revision 67834: Pruning some branches. This was merged a long time ago. Changed: D Zope/branches/regebro-issue_1888/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/ When you add roles in manage_access, roles are now stripped of any leading or trailing
Log message for revision 67839: When you add roles in manage_access, roles are now stripped of any leading or trailing spaces. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/AccessControl/Role.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2006-05-02 14:09:09 UTC (rev 67838) +++ Zope/trunk/doc/CHANGES.txt 2006-05-02 14:22:06 UTC (rev 67839) @@ -240,6 +240,8 @@ from the Zope 3 source tree (to get rid of redundant packages) Bugs Fixed + - When you add roles in manage_access, roles are now stripped of +any leading or trailing spaces. - Collector #2062: Fix manage_historyCopy, which was broken, and write tests for it. Modified: Zope/trunk/lib/python/AccessControl/Role.py === --- Zope/trunk/lib/python/AccessControl/Role.py 2006-05-02 14:09:09 UTC (rev 67838) +++ Zope/trunk/lib/python/AccessControl/Role.py 2006-05-02 14:22:06 UTC (rev 67839) @@ -473,7 +473,7 @@ if submit=='Add Role': -role=reqattr(REQUEST, 'role') +role=reqattr(REQUEST, 'role').strip() return self._addRole(role, REQUEST) if submit=='Delete Role': ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/Products/PythonScripts/tests/testPythonScript.py Temporarily getting rid of an annoying error.
Log message for revision 67784: Temporarily getting rid of an annoying error. Changed: U Zope/branches/regebro-wsgi_support2/lib/python/Products/PythonScripts/tests/testPythonScript.py -=- Modified: Zope/branches/regebro-wsgi_support2/lib/python/Products/PythonScripts/tests/testPythonScript.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Products/PythonScripts/tests/testPythonScript.py 2006-05-01 09:47:46 UTC (rev 67783) +++ Zope/branches/regebro-wsgi_support2/lib/python/Products/PythonScripts/tests/testPythonScript.py 2006-05-01 10:11:02 UTC (rev 67784) @@ -223,7 +223,8 @@ def testBadImports(self): self.assertPSRaises(ImportError, body=from string import *) -self.assertPSRaises(ImportError, body=import mmap) +self.assertPSRaises(ImportError, body=from datetime import datetime) +#self.assertPSRaises(ImportError, body=import mmap) def testAttributeAssignment(self): # It's illegal to assign to attributes of anything that ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/ Neater shutdown with twisted.
Log message for revision 67785: Neater shutdown with twisted. Changed: U Zope/branches/regebro-wsgi_support2/lib/python/Lifetime/__init__.py U Zope/branches/regebro-wsgi_support2/lib/python/ZServer/HTTPResponse.py U Zope/branches/regebro-wsgi_support2/lib/python/ZServer/PubCore/ZServerPublisher.py U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py -=- Modified: Zope/branches/regebro-wsgi_support2/lib/python/Lifetime/__init__.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Lifetime/__init__.py 2006-05-01 10:11:02 UTC (rev 67784) +++ Zope/branches/regebro-wsgi_support2/lib/python/Lifetime/__init__.py 2006-05-01 10:12:03 UTC (rev 67785) @@ -31,6 +31,11 @@ import ZServer ZServer.exit_code = exit_code _shutdown_phase = 1 +try: +from twisted.internet import reactor +reactor.callLater(0.1, reactor.stop) +except ImportError: +pass if fast: # Someone wants us to shutdown fast. This is hooked into SIGTERM - so # possibly the system is going down and we can expect a SIGKILL within Modified: Zope/branches/regebro-wsgi_support2/lib/python/ZServer/HTTPResponse.py === --- Zope/branches/regebro-wsgi_support2/lib/python/ZServer/HTTPResponse.py 2006-05-01 10:11:02 UTC (rev 67784) +++ Zope/branches/regebro-wsgi_support2/lib/python/ZServer/HTTPResponse.py 2006-05-01 10:12:03 UTC (rev 67785) @@ -313,6 +313,7 @@ def start_response(self, status, headers, exc_info=None): # Used for WSGI +self._request.reply_code = int(status.split(' ')[0]) status = 'HTTP/%s %s\r\n' % (self._request.version, status) self.write(status) headers = '\r\n'.join([': '.join(x) for x in headers]) Modified: Zope/branches/regebro-wsgi_support2/lib/python/ZServer/PubCore/ZServerPublisher.py === --- Zope/branches/regebro-wsgi_support2/lib/python/ZServer/PubCore/ZServerPublisher.py 2006-05-01 10:11:02 UTC (rev 67784) +++ Zope/branches/regebro-wsgi_support2/lib/python/ZServer/PubCore/ZServerPublisher.py 2006-05-01 10:12:03 UTC (rev 67785) @@ -33,5 +33,6 @@ for r in res: a['wsgi.output'].write(r) finally: +# TODO: Support keeping connections open. a['wsgi.output']._close = 1 a['wsgi.output'].close() Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-05-01 10:11:02 UTC (rev 67784) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-05-01 10:12:03 UTC (rev 67785) @@ -115,12 +115,15 @@ try: from App.config import getConfiguration config = getConfiguration() +import ZServer if config.twisted_servers: if not _use_twisted: raise ImportError(You do not have twisted installed.) twisted.internet.reactor.run() +# Storing the exit code in the ZServer even for twisted, +# but hey, it works... +sys.exit(ZServer.exit_code) else: -import ZServer import Lifetime Lifetime.loop() sys.exit(ZServer.exit_code) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py Added an error message for misconfiguration.
Log message for revision 67790: Added an error message for misconfiguration. Changed: U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py -=- Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-05-01 11:19:56 UTC (rev 67789) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-05-01 11:24:08 UTC (rev 67790) @@ -116,9 +116,13 @@ from App.config import getConfiguration config = getConfiguration() import ZServer +if config.twisted_servers and config.servers: +raise ZConfig.ConfigurationError( +You can't run both ZServer servers and twisted servers.) if config.twisted_servers: if not _use_twisted: -raise ImportError(You do not have twisted installed.) +raise ZConfig.ConfigurationError( +You do not have twisted installed.) twisted.internet.reactor.run() # Storing the exit code in the ZServer even for twisted, # but hey, it works... ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/ Added CHANGES changes, and the new stuff into skel.
Log message for revision 67793: Added CHANGES changes, and the new stuff into skel. Changed: U Zope/branches/regebro-wsgi_support2/doc/CHANGES.txt U Zope/branches/regebro-wsgi_support2/skel/etc/zope.conf.in -=- Modified: Zope/branches/regebro-wsgi_support2/doc/CHANGES.txt === --- Zope/branches/regebro-wsgi_support2/doc/CHANGES.txt 2006-05-01 12:06:18 UTC (rev 67792) +++ Zope/branches/regebro-wsgi_support2/doc/CHANGES.txt 2006-05-01 12:59:29 UTC (rev 67793) @@ -48,6 +48,27 @@ - Using FastCGI is offically deprecated. Features added + + - Experimental WSGI and Twisted support for http. +Zope now has a WSGI interface for integration with other +web-servers than ZServer. Most notably Twisted is supported. +The WSGI application is ZPublisher.WSGIPublisher.publish_module + +You can make ZServer use the twisted interface with the +use-wsgi on keyword in the http-server section in zope.conf. + +You can run Twisted by installing Twisted (2.1 recommended) and +replacing the http-server section with a server section in +zope.conf. It is not possible to run a Twisted server together with +a ZServer at the same time. + + server +address 8080 +type Zope2-HTTP + /server + +WSGI: http://www.python.org/dev/peps/pep-0333/ +Twisted: http://twistedmatrix.com/ - The traversal has been refactored to take heed of Zope3s IPublishTraverse adapter interfaces. The ZCML directives Modified: Zope/branches/regebro-wsgi_support2/skel/etc/zope.conf.in === --- Zope/branches/regebro-wsgi_support2/skel/etc/zope.conf.in 2006-05-01 12:06:18 UTC (rev 67792) +++ Zope/branches/regebro-wsgi_support2/skel/etc/zope.conf.in 2006-05-01 12:59:29 UTC (rev 67793) @@ -904,6 +904,8 @@ # valid keys are address and force-connection-close address 8080 # force-connection-close on + # You can also use the WSGI interface between ZServer and ZPublisher: + # use-wsgi on /http-server # Examples: @@ -947,6 +949,13 @@ #user admin #password 123 # /clock-server +# +# server +## This uses Twisted as the web-server. You must install Twisted +## separately. You can't run Twisted and ZServer at same time. +#address 8080 +#type Zope2-HTTP +# /server # Database (zodb_db) section ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/ Experimental WSGI + Twisted support.
Log message for revision 67794: Experimental WSGI + Twisted support. Merge from svn+ssh://[EMAIL PROTECTED]/repos/main/Zope/branches/regebro-wsgi_support2 Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/Lifetime/__init__.py U Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py U Zope/trunk/lib/python/ZPublisher/Publish.py A Zope/trunk/lib/python/ZPublisher/WSGIPublisher.py U Zope/trunk/lib/python/ZServer/HTTPResponse.py U Zope/trunk/lib/python/ZServer/HTTPServer.py U Zope/trunk/lib/python/ZServer/PubCore/ZServerPublisher.py U Zope/trunk/lib/python/ZServer/component.xml U Zope/trunk/lib/python/ZServer/datatypes.py U Zope/trunk/lib/python/Zope2/Startup/__init__.py U Zope/trunk/lib/python/Zope2/Startup/datatypes.py U Zope/trunk/lib/python/Zope2/Startup/handlers.py U Zope/trunk/lib/python/Zope2/Startup/zopeschema.xml U Zope/trunk/skel/etc/zope.conf.in -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2006-05-01 12:59:29 UTC (rev 67793) +++ Zope/trunk/doc/CHANGES.txt 2006-05-01 13:17:32 UTC (rev 67794) @@ -48,6 +48,27 @@ - Using FastCGI is offically deprecated. Features added + + - Experimental WSGI and Twisted support for http. +Zope now has a WSGI interface for integration with other +web-servers than ZServer. Most notably Twisted is supported. +The WSGI application is ZPublisher.WSGIPublisher.publish_module + +You can make ZServer use the twisted interface with the +use-wsgi on keyword in the http-server section in zope.conf. + +You can run Twisted by installing Twisted (2.1 recommended) and +replacing the http-server section with a server section in +zope.conf. It is not possible to run a Twisted server together with +a ZServer at the same time. + + server +address 8080 +type Zope2-HTTP + /server + +WSGI: http://www.python.org/dev/peps/pep-0333/ +Twisted: http://twistedmatrix.com/ - The traversal has been refactored to take heed of Zope3s IPublishTraverse adapter interfaces. The ZCML directives Modified: Zope/trunk/lib/python/Lifetime/__init__.py === --- Zope/trunk/lib/python/Lifetime/__init__.py 2006-05-01 12:59:29 UTC (rev 67793) +++ Zope/trunk/lib/python/Lifetime/__init__.py 2006-05-01 13:17:32 UTC (rev 67794) @@ -31,6 +31,11 @@ import ZServer ZServer.exit_code = exit_code _shutdown_phase = 1 +try: +from twisted.internet import reactor +reactor.callLater(0.1, reactor.stop) +except ImportError: +pass if fast: # Someone wants us to shutdown fast. This is hooked into SIGTERM - so # possibly the system is going down and we can expect a SIGKILL within Modified: Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py === --- Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2006-05-01 12:59:29 UTC (rev 67793) +++ Zope/trunk/lib/python/Products/PythonScripts/tests/testPythonScript.py 2006-05-01 13:17:32 UTC (rev 67794) @@ -223,7 +223,8 @@ def testBadImports(self): self.assertPSRaises(ImportError, body=from string import *) -self.assertPSRaises(ImportError, body=import mmap) +self.assertPSRaises(ImportError, body=from datetime import datetime) +#self.assertPSRaises(ImportError, body=import mmap) def testAttributeAssignment(self): # It's illegal to assign to attributes of anything that Modified: Zope/trunk/lib/python/ZPublisher/Publish.py === --- Zope/trunk/lib/python/ZPublisher/Publish.py 2006-05-01 12:59:29 UTC (rev 67793) +++ Zope/trunk/lib/python/ZPublisher/Publish.py 2006-05-01 13:17:32 UTC (rev 67794) @@ -122,7 +122,6 @@ return response except: - # DM: provide nicer error message for FTP sm = None if response is not None: Copied: Zope/trunk/lib/python/ZPublisher/WSGIPublisher.py (from rev 67793, Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py) Modified: Zope/trunk/lib/python/ZServer/HTTPResponse.py === --- Zope/trunk/lib/python/ZServer/HTTPResponse.py 2006-05-01 12:59:29 UTC (rev 67793) +++ Zope/trunk/lib/python/ZServer/HTTPResponse.py 2006-05-01 13:17:32 UTC (rev 67794) @@ -311,6 +311,16 @@ self._close=1 self._request.reply_code=response.status +def start_response(self, status, headers, exc_info=None): +# Used for WSGI +
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/ Twisted support.
Log message for revision 67759: Twisted support. Changed: U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/zopeschema.xml -=- Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-04-30 08:25:20 UTC (rev 67758) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-04-30 09:28:13 UTC (rev 67759) @@ -20,12 +20,11 @@ import socket from re import compile from socket import gethostbyaddr +import twisted.internet.reactor import ZConfig - from ZConfig.components.logger import loghandler - logger = logging.getLogger(Zope) started = False @@ -96,7 +95,10 @@ self.makePidFile() self.setupInterpreter() self.startZope() -self.registerSignals() +from App.config import getConfiguration +config = getConfiguration() +if not config.twisted_servers: +self.registerSignals() # emit a ready message in order to prevent the kinds of emails # to the Zope maillist in which people claim that Zope has frozen # after it has emitted ZServer messages. @@ -106,10 +108,15 @@ def run(self): # the mainloop. try: -import ZServer -import Lifetime -Lifetime.loop() -sys.exit(ZServer.exit_code) +from App.config import getConfiguration +config = getConfiguration() +if config.twisted_servers: +twisted.internet.reactor.run() +else: +import ZServer +import Lifetime +Lifetime.loop() +sys.exit(ZServer.exit_code) finally: self.shutdown() Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py 2006-04-30 08:25:20 UTC (rev 67758) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/handlers.py 2006-04-30 09:28:13 UTC (rev 67759) @@ -1,8 +1,15 @@ import os import sys +import time +import logging from re import compile from socket import gethostbyaddr +import twisted.internet +from twisted.application.service import MultiService +import zope.app.appsetup.interfaces +import zope.app.twisted.main + # top-level key handlers @@ -133,7 +140,7 @@ 'catalog-getObject-raises' option will be removed in Zope 2.10:\n, DeprecationWarning) -from Products.ZCatalog import CatalogBrains +from Products.ZCatalog import CatalogBrains CatalogBrains.GETOBJECT_RAISES = bool(value) return value @@ -143,7 +150,8 @@ def root_handler(config): Mutate the configuration with defaults and perform fixups of values that require knowledge about configuration -values outside of their context. +values outside of their context. + # Set environment variables for k,v in config.environment.items(): @@ -165,7 +173,7 @@ instanceprod = os.path.join(config.instancehome, 'Products') if instanceprod not in config.products: config.products.append(instanceprod) - + import Products L = [] for d in config.products + Products.__path__: @@ -190,6 +198,23 @@ config.cgi_environment, config.port_base) +if not config.twisted_servers: +config.twisted_servers = [] +else: +# Set number of threads (reuse zserver_threads variable) +twisted.internet.reactor.suggestThreadPoolSize(config.zserver_threads) + +# Create a root service +rootService = MultiService() + +for server in config.twisted_servers: +service = server.create(None) +service.setServiceParent(rootService) + +rootService.startService() +twisted.internet.reactor.addSystemEventTrigger( +'before', 'shutdown', rootService.stopService) + # set up trusted proxies if config.trusted_proxies: import ZPublisher.HTTPRequest @@ -217,3 +242,29 @@ if isIp_(host): return [host] return gethostbyaddr(host)[2] +# XXX Need to find a better place for this. + +import twisted.web2.wsgi +import twisted.web2.server +import twisted.web2.log + +try: +from twisted.web2.http import HTTPFactory +except ImportError: +from twisted.web2.channel.http import HTTPFactory + +from zope.component import provideUtility +from zope.app.twisted.server import ServerType, SSLServerType +from zope.app.twisted.interfaces import IServerType +from
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py I can't believe I forgot this file, and then deleted it.
Log message for revision 67767: I can't believe I forgot this file, and then deleted it. Changed: A Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py -=- Added: Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py === --- Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py 2006-04-30 15:25:18 UTC (rev 67766) +++ Zope/branches/regebro-wsgi_support2/lib/python/ZPublisher/WSGIPublisher.py 2006-04-30 15:40:18 UTC (rev 67767) @@ -0,0 +1,477 @@ +## +# +# Copyright (c) 2002 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 +# +## +__doc__=Python Object Publisher -- Publish Python objects on web servers + +$Id: Publish.py 67721 2006-04-28 14:57:35Z regebro $ + +import sys, os, re, time +import transaction +from Response import Response +from Request import Request +from maybe_lock import allocate_lock +from mapply import mapply +from zExceptions import Redirect +from cStringIO import StringIO +from ZServer.medusa.http_date import build_http_date + +class WSGIResponse(Response): +A response object for WSGI + +This Response object knows nothing about ZServer, but tries to be +compatible with the ZServerHTTPResponse. + +Most significantly, streaming is not (yet) supported. + +_streaming = 0 + +def __str__(self, +html_search=re.compile('html',re.I).search, +): +if self._wrote: +if self._chunking: +return '0\r\n\r\n' +else: +return '' + +headers=self.headers +body=self.body + +# set 204 (no content) status if 200 and response is empty +# and not streaming +if not headers.has_key('content-type') and \ +not headers.has_key('content-length') and \ +not self._streaming and \ +self.status == 200: +self.setStatus('nocontent') + +# add content length if not streaming +if not headers.has_key('content-length') and \ +not self._streaming: +self.setHeader('content-length',len(body)) + + +content_length= headers.get('content-length', None) +if content_length0 : +self.setHeader('content-length', content_length) + +headersl=[] +append=headersl.append + +status=headers.get('status', '200 OK') + +# status header must come first. +append(HTTP/%s %s % (self._http_version or '1.0' , status)) +if headers.has_key('status'): +del headers['status'] + +# add zserver headers +append('Server: %s' % self._server_version) +append('Date: %s' % build_http_date(time.time())) + +if self._http_version=='1.0': +if self._http_connection=='keep-alive' and \ +self.headers.has_key('content-length'): +self.setHeader('Connection','Keep-Alive') +else: +self.setHeader('Connection','close') + +# Close the connection if we have been asked to. +# Use chunking if streaming output. +if self._http_version=='1.1': +if self._http_connection=='close': +self.setHeader('Connection','close') +elif not self.headers.has_key('content-length'): +if self.http_chunk and self._streaming: +self.setHeader('Transfer-Encoding','chunked') +self._chunking=1 +else: +self.setHeader('Connection','close') + +for key, val in headers.items(): +if key.lower()==key: +# only change non-literal header names +key=%s%s % (key[:1].upper(), key[1:]) +start=0 +l=key.find('-',start) +while l = start: +key=%s-%s%s % (key[:l],key[l+1:l+2].upper(),key[l+2:]) +start=l+1 +l=key.find('-',start) +append(%s: %s % (key, val)) +if self.cookies: +headersl=headersl+self._cookie_list() +headersl[len(headersl):]=[self.accumulated_headers, body] +return \r\n.join(headersl) + + +class Retry(Exception): +Raise this to retry a request + + +def __init__(self, t=None, v=None, tb=None): +
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/ More twisted imports handled.
Log message for revision 67770: More twisted imports handled. Changed: U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/datatypes.py U Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/zopeschema.xml -=- Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-04-30 16:13:46 UTC (rev 67769) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/__init__.py 2006-04-30 16:25:51 UTC (rev 67770) @@ -20,7 +20,12 @@ import socket from re import compile from socket import gethostbyaddr -import twisted.internet.reactor +try: +import twisted.internet.reactor +_use_twisted = True +except ImportError: +_use_twisted = True + import ZConfig from ZConfig.components.logger import loghandler @@ -111,6 +116,8 @@ from App.config import getConfiguration config = getConfiguration() if config.twisted_servers: +if not _use_twisted: +raise ValueError, You do not have twisted installed. twisted.internet.reactor.run() else: import ZServer Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/datatypes.py === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/datatypes.py 2006-04-30 16:13:46 UTC (rev 67769) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/datatypes.py 2006-04-30 16:25:51 UTC (rev 67770) @@ -339,3 +339,10 @@ # Zope class factory. This no longer works with the implementation of # mounted databases, so we just use the zopeClassFactory as the default +try: +from zope.app.twisted.server import ServerFactory +class TwistedServerFactory(ServerFactory): +pass +except ImportError: +class TwistedServerFactory: +pass Modified: Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/zopeschema.xml === --- Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/zopeschema.xml 2006-04-30 16:13:46 UTC (rev 67769) +++ Zope/branches/regebro-wsgi_support2/lib/python/Zope2/Startup/zopeschema.xml 2006-04-30 16:25:51 UTC (rev 67770) @@ -11,7 +11,7 @@ import package=tempstorage/ import package=Zope2.Startup file=warnfilter.xml/ - sectiontype name=server datatype=zope.app.twisted.server.ServerFactory + sectiontype name=server datatype=Zope2.Startup.datatypes.TwistedServerFactory key name=type required=yes / key name=address datatype=inet-address / key name=backlog datatype=integer default=50 / ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversal_refactor/ Removed last rests of Traversable usage. Deprecated Traversable and FiveTraversable.
Log message for revision 67698: Removed last rests of Traversable usage. Deprecated Traversable and FiveTraversable. Changed: U Products.Five/branches/regebro-traversal_refactor/browser/adding.py U Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py U Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py U Products.Five/branches/regebro-traversal_refactor/traversable.py -=- Modified: Products.Five/branches/regebro-traversal_refactor/browser/adding.py === --- Products.Five/branches/regebro-traversal_refactor/browser/adding.py 2006-04-28 08:54:44 UTC (rev 67697) +++ Products.Five/branches/regebro-traversal_refactor/browser/adding.py 2006-04-28 09:25:33 UTC (rev 67698) @@ -37,7 +37,7 @@ from zExceptions import BadRequest from Products.Five import BrowserView -from Products.Five.traversable import Traversable + from Products.Five.browser.pagetemplatefile import ZopeTwoPageTemplateFile from Acquisition import Implicit @@ -202,7 +202,7 @@ return True return False -class ContentAdding(Adding, Traversable, SimpleItem): +class ContentAdding(Adding, SimpleItem): menu_id = add_content Modified: Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py === --- Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-28 08:54:44 UTC (rev 67697) +++ Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-28 09:25:33 UTC (rev 67698) @@ -38,8 +38,6 @@ from zope.app.component.metaconfigure import adapter from zope.app.security.interfaces import IPermission -#from Products.Five.viewable import Viewable -from Products.Five.traversable import Traversable from Products.Five.bridge import fromZ2Interface from Products.Five.browser.metaconfigure import page from Products.Five.interfaces import IBrowserDefault @@ -113,41 +111,10 @@ def isFiveMethod(m): return hasattr(m, '__five_method__') -_traversable_monkies = [] -def classTraversable(class_): -# If a class already has this attribute, it means it is either a -# subclass of Traversable or was already processed with this -# directive; in either case, do nothing... except in the case were -# the class overrides __bobo_traverse__ instead of getting it from -# a base class. In this case, we suppose that the class probably -# didn't bother with the base classes __bobo_traverse__ anyway and -# we step __fallback_traverse__. -if hasattr(class_, '__five_traversable__'): -if (hasattr(class_, '__bobo_traverse__') and -isFiveMethod(class_.__bobo_traverse__)): -return - -if (hasattr(class_, '__bobo_traverse__') and -not isFiveMethod(class_.__bobo_traverse__)): -# if there's an existing bobo_traverse hook already, use that -# as the traversal fallback method -setattr(class_, '__fallback_traverse__', class_.__bobo_traverse__) - -setattr(class_, '__bobo_traverse__', -Traversable.__bobo_traverse__.im_func) -setattr(class_, '__five_traversable__', True) -# remember class for clean up -_traversable_monkies.append(class_) - def traversable(_context, class_): warnings.warn(The five:traversable statement is no longer needed \ and will be removed in Zope 2.12, DeprecationWarning) -_context.action( -discriminator = None, -callable = classTraversable, -args = (class_,) -) def defaultViewable(_context, class_): if zope.deprecation.__show__(): @@ -259,17 +226,6 @@ except (AttributeError, KeyError): pass -def untraversable(class_): -Restore class's initial state with respect to traversability -killMonkey(class_, '__bobo_traverse__', '__fallback_traverse__', - '__five_traversable__') - -#def undefaultViewable(class_): -#Restore class's initial state with respect to being default -#viewable. -#killMonkey(class_, '__browser_default__', '__fallback_default__', - #'__five_viewable__') - def unregisterClass(class_): delattr(class_, 'meta_type') try: @@ -278,16 +234,7 @@ pass def cleanUp(): -global _traversable_monkies -for class_ in _traversable_monkies: -untraversable(class_) -_traversable_monkies = [] -#global _defaultviewable_monkies -#for class_ in _defaultviewable_monkies: -#undefaultViewable(class_) -#_defaultviewable_monkies = [] - global _register_monkies for class_ in _register_monkies: unregisterClass(class_) Modified: Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py === --- Products.Five/branches/regebro-traversal_refactor/tests/testing/folder.py
[Zope-Checkins] SVN: Zope/branches/regebro-wsgi_refactor/lib/python/Z Finish up
Log message for revision 67721: Finish up Changed: U Zope/branches/regebro-wsgi_refactor/lib/python/ZPublisher/Publish.py U Zope/branches/regebro-wsgi_refactor/lib/python/ZServer/HTTPServer.py -=- Modified: Zope/branches/regebro-wsgi_refactor/lib/python/ZPublisher/Publish.py === --- Zope/branches/regebro-wsgi_refactor/lib/python/ZPublisher/Publish.py 2006-04-28 14:01:48 UTC (rev 67720) +++ Zope/branches/regebro-wsgi_refactor/lib/python/ZPublisher/Publish.py 2006-04-28 14:57:35 UTC (rev 67721) @@ -73,7 +73,6 @@ parents=None response=None - try: request.processInputs() @@ -185,7 +184,7 @@ response = ZServerHTTPResponse(stdout=environ['wsgi.output'], stderr=StringIO()) response._http_version = environ['SERVER_PROTOCOL'].split('/')[1] -response._http_connection = environ['CONNECTION_TYPE'] +response._http_connection = environ.get('CONNECTION_TYPE', 'close') response._server_version = environ['SERVER_SOFTWARE'] request = Request(environ['wsgi.input'], environ, response) @@ -215,7 +214,7 @@ result=str(response) # Return the result body iterable. request.close() -#response._finish(0) +response._finish(0) return (result,) @@ -238,10 +237,6 @@ env = environ.copy() else: env = request - -if not env.has_key('CONNECTION_TYPE'): -print env -env['wsgi.input']= sys.stdin env['wsgi.errors'] = sys.stderr env['wsgi.version'] = (1,0) env['wsgi.multithread'] = True @@ -250,12 +245,14 @@ env['wsgi.url_scheme'] = env['SERVER_PROTOCOL'].split('/')[0] if not env.has_key('wsgi.output'): env['wsgi.output'] = stdout +if not env.has_key('wsgi.input'): +env['wsgi.input']= stdin application = WSGIPublisherApplication() body = application(env, wsgi_start_response) -env['wsgi.output'].write(body[0]) +for b in body: +env['wsgi.output'].write(b) env['wsgi.output'].close() - # The module defined a post-access function, call it if after_list[0] is not None: after_list[0]() Modified: Zope/branches/regebro-wsgi_refactor/lib/python/ZServer/HTTPServer.py === --- Zope/branches/regebro-wsgi_refactor/lib/python/ZServer/HTTPServer.py 2006-04-28 14:01:48 UTC (rev 67720) +++ Zope/branches/regebro-wsgi_refactor/lib/python/ZServer/HTTPServer.py 2006-04-28 14:57:35 UTC (rev 67721) @@ -264,6 +264,7 @@ env=self.get_environment(request) env['wsgi.output'] = ChannelPipe(request) +env['wsgi.input'] = sin version = request.version if version=='1.0' and is_proxying_match(request.request): # a request that was made as if this zope was an http 1.0 proxy. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversal_refactor/ Branch for Five support of the traversal refactoring.
Log message for revision 67633: Branch for Five support of the traversal refactoring. Changed: A Products.Five/branches/regebro-traversal_refactor/ -=- Copied: Products.Five/branches/regebro-traversal_refactor (from rev 67632, Products.Five/trunk) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversal_refactor/ Removed some no longer used code.
Log message for revision 67647: Removed some no longer used code. Deprecated the no longer needed BrowserDefault adapter. Changed: U Products.Five/branches/regebro-traversal_refactor/browser/tests/defaultview.zcml U Products.Five/branches/regebro-traversal_refactor/browser/tests/test_defaultview.py U Products.Five/branches/regebro-traversal_refactor/browser/tests/test_recurse.py U Products.Five/branches/regebro-traversal_refactor/configure.zcml U Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py U Products.Five/branches/regebro-traversal_refactor/tests/test_viewable.py U Products.Five/branches/regebro-traversal_refactor/tests/viewable.txt U Products.Five/branches/regebro-traversal_refactor/viewable.py -=- Modified: Products.Five/branches/regebro-traversal_refactor/browser/tests/defaultview.zcml === --- Products.Five/branches/regebro-traversal_refactor/browser/tests/defaultview.zcml 2006-04-27 14:08:06 UTC (rev 67646) +++ Products.Five/branches/regebro-traversal_refactor/browser/tests/defaultview.zcml 2006-04-27 15:07:44 UTC (rev 67647) @@ -2,9 +2,6 @@ xmlns:browser=http://namespaces.zope.org/browser; xmlns:five=http://namespaces.zope.org/five; - five:defaultViewable - class=Products.Five.tests.testing.simplecontent.SimpleContent / - browser:page for=Products.Five.tests.testing.simplecontent.ISimpleContent name=eagledefaultview.txt Modified: Products.Five/branches/regebro-traversal_refactor/browser/tests/test_defaultview.py === --- Products.Five/branches/regebro-traversal_refactor/browser/tests/test_defaultview.py 2006-04-27 14:08:06 UTC (rev 67646) +++ Products.Five/branches/regebro-traversal_refactor/browser/tests/test_defaultview.py 2006-04-27 15:07:44 UTC (rev 67647) @@ -46,7 +46,18 @@ uf = self.folder.acl_users uf._doAddUser('manager', 'r00t', ['Manager'], []) -Test that index.html is still the default view: +BBB This is a test of backwards comaptibility with Five 1.3/Zope2.9. +The deprecated directive five:defaultViewable would before make +index.html the default view. Test that this is still the case. +five:defaultViewable goes away in Zope 2.12, and this test goes then too: + import zope.deprecation + zope.deprecation.__show__.off() + zcml.load_string(''' + ... configure xmlns:five=http://namespaces.zope.org/five; + ... five:defaultViewable + ... class=Products.Five.tests.testing.simplecontent.SimpleContent / + ... /configure''') + zope.deprecation.__show__.on() print http(r''' ... GET /test_folder_1_/testoid HTTP/1.1 ... Authorization: Basic manager:r00t Modified: Products.Five/branches/regebro-traversal_refactor/browser/tests/test_recurse.py === --- Products.Five/branches/regebro-traversal_refactor/browser/tests/test_recurse.py 2006-04-27 14:08:06 UTC (rev 67646) +++ Products.Five/branches/regebro-traversal_refactor/browser/tests/test_recurse.py 2006-04-27 15:07:44 UTC (rev 67647) @@ -42,12 +42,8 @@ ... return 'foo' ... -Now we make the class default viewable and register a default view -name for it: +Now we register a default view name for the class: - from Products.Five.fiveconfigure import classDefaultViewable - #classDefaultViewable(Recurse) - from zope.component import provideAdapter from zope.publisher.interfaces.browser import IBrowserRequest from zope.component.interfaces import IDefaultViewName Modified: Products.Five/branches/regebro-traversal_refactor/configure.zcml === --- Products.Five/branches/regebro-traversal_refactor/configure.zcml 2006-04-27 14:08:06 UTC (rev 67646) +++ Products.Five/branches/regebro-traversal_refactor/configure.zcml 2006-04-27 15:07:44 UTC (rev 67647) @@ -29,12 +29,6 @@ provides=zope.app.traversing.interfaces.ITraverser / - adapter - for=* - factory=.viewable.BrowserDefault - provides=.interfaces.IBrowserDefault - / - !-- this is really lying, but it's to please checkContainer -- five:implements class=OFS.ObjectManager.ObjectManager interface=zope.app.container.interfaces.IContainer / Modified: Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py === --- Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-27 14:08:06 UTC (rev 67646) +++ Products.Five/branches/regebro-traversal_refactor/fiveconfigure.py 2006-04-27 15:07:44 UTC (rev 67647) @@ -26,6 +26,7 @@ import App.config import Products +import
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py queryDefaultName isn't deprecated in 3.3, so I start using it instead.
Log message for revision 67648: queryDefaultName isn't deprecated in 3.3, so I start using it instead. Changed: U Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-27 15:07:44 UTC (rev 67647) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-27 15:08:11 UTC (rev 67648) @@ -24,6 +24,7 @@ from zope.component.interfaces import ComponentLookupError from zope.event import notify from zope.app.publication.interfaces import EndRequestEvent +from zope.app.publisher.browser import queryDefaultViewName from zope.publisher.interfaces import IPublishTraverse from zope.publisher.interfaces import NotFound from zope.component.interfaces import IDefaultViewName @@ -116,15 +117,7 @@ # Zope 3.2 still uses IDefaultView name when it # registeres default views, even though it's # deprecated. So we handle that here: -try: -sm = getSiteManager(self.context) -except ComponentLookupError: -# Context has no context (typically Application). -# Just look up the global site manager -sm = getSiteManager() -default_name = sm.adapters.lookup( -map(providedBy, (self.context, request)), -IDefaultViewName) +default_name = queryDefaultViewName(self.context, request) if default_name is not None: return self.context, (default_name,) return self.context, () ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-traversal_refactor/ Five runs error free, and I need to go home.
Log message for revision 67670: Five runs error free, and I need to go home. Changed: U Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py U Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py -=- Modified: Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py === --- Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py 2006-04-27 20:38:38 UTC (rev 67669) +++ Products.Five/branches/regebro-traversal_refactor/browser/TrustedExpression.py 2006-04-27 20:39:35 UTC (rev 67670) @@ -29,6 +29,19 @@ ModuleImporter = SecureModuleImporter +from zope.publisher.interfaces.browser import IBrowserRequest +from zope.interface import implements, Interface +from zope.app.publication.browser import setDefaultSkin +from zope.app.traversing.namespace import nsParse +from zope.app.traversing.namespace import namespaceLookup +from zope.component import queryMultiAdapter + +class FakeRequest(dict): + implements(IBrowserRequest) + + def getURL(self): +return http://codespeak.net/z3/five; + def trustedTraverse(ob, path, ignored,): if not path: return self @@ -40,7 +53,11 @@ if isinstance(path, str): path = path.split('/') else: path=list(path) - REQUEST={'TraversalRequestNameStack': path} + REQUEST = get(ob, 'REQUEST', None) + if REQUEST is None: +REQUEST=FakeRequest() + setDefaultSkin(REQUEST) + REQUEST['TraversalRequestNameStack'] = path path.reverse() pop=path.pop @@ -64,6 +81,17 @@ object=o continue +if name and name[:1] in '@+': + # Process URI segment parameters. + ns, nm = nsParse(name) + if ns: +try: + o = namespaceLookup(ns, nm, object, REQUEST).__of__(object) +except TraversalError: + raise KeyError(name) +object = o +continue + t=get(object, '__bobo_traverse__', M) if t is not M: o=t(REQUEST, name) else: @@ -71,7 +99,11 @@ if o is M: try: o = object[name] except (AttributeError, TypeError): # better exception - raise AttributeError(name) +o = queryMultiAdapter((object, REQUEST), Interface, name) +if o is not None: +o = o.__of__(object) +else: +raise AttributeError(name) object = o return object Modified: Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py === --- Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py 2006-04-27 20:38:38 UTC (rev 67669) +++ Products.Five/branches/regebro-traversal_refactor/tests/testing/simplecontent.py 2006-04-27 20:39:35 UTC (rev 67670) @@ -20,7 +20,6 @@ from AccessControl import ClassSecurityInfo from zope.interface import Interface, implements -from Products.Five.traversable import Traversable class ISimpleContent(Interface): pass @@ -31,7 +30,7 @@ class IIndexSimpleContent(ISimpleContent): pass -class SimpleContent(Traversable, SimpleItem): +class SimpleContent(SimpleItem): implements(ISimpleContent) meta_type = 'Five SimpleContent' ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/lib/python/ Further on the path.... but not yet done.
Log message for revision 67671: Further on the path but not yet done. Changed: U Zope/branches/easter-sprint_traversal-refactor/lib/python/OFS/Traversable.py U Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/OFS/Traversable.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/OFS/Traversable.py 2006-04-27 20:39:35 UTC (rev 67670) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/OFS/Traversable.py 2006-04-27 20:40:05 UTC (rev 67671) @@ -25,9 +25,14 @@ from Acquisition import Acquired, aq_inner, aq_parent, aq_base from zExceptions import NotFound from ZODB.POSException import ConflictError -from zope.interface import implements +from zope.interface import implements, Interface from interfaces import ITraversable +from zope.app.traversing.interfaces import ITraversable as IZope3Traversable +from zope.component import queryMultiAdapter +from zope.app.traversing.interfaces import TraversalError +from zope.app.traversing.namespace import nsParse +from zope.app.traversing.namespace import namespaceLookup _marker = object() @@ -59,6 +64,7 @@ return self.virtual_url_path() spp = self.getPhysicalPath() + try: toUrl = self.REQUEST.physicalPathToURL except AttributeError: @@ -133,7 +139,6 @@ If true, then all of the objects along the path are validated with the security machinery. Usually invoked using restrictedTraverse(). - if not path: return self @@ -188,7 +193,19 @@ continue bobo_traverse = _getattr(obj, '__bobo_traverse__', _none) -if bobo_traverse is not _none: +if name and name[:1] in '@+': +# Process URI segment parameters. +ns, nm = nsParse(name) +if ns: +try: +next = namespaceLookup(ns, nm, obj, + self.REQUEST).__of__(obj) +if restricted and not securityManager.validate( +obj, obj, _none, next): +raise Unauthorized, name +except TraversalError: +raise AttributeError(name) +elif bobo_traverse is not _none: next = bobo_traverse(REQUEST, name) if restricted: if aq_base(next) is not next: @@ -216,11 +233,19 @@ next = _getattr(obj, name, marker) if next is marker: try: -next=obj[name] -except AttributeError: -# Raise NotFound for easier debugging -# instead of AttributeError: __getitem__ -raise NotFound, name +try: +next=obj[name] +except AttributeError: +# Raise NotFound for easier debugging +# instead of AttributeError: __getitem__ +raise NotFound, name +except (NotFound, KeyError): +# Try to look for a view +next = queryMultiAdapter((obj, self.REQUEST), + Interface, name).__of__(obj) +if next is None: +# Didn't find one, reraise the error: +raise if restricted and not securityManager.validate( obj, obj, _none, next): raise Unauthorized, name Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-27 20:39:35 UTC (rev 67670) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-27 20:40:05 UTC (rev 67671) @@ -16,9 +16,9 @@ from urllib import quote import xmlrpc -from zExceptions import Forbidden, Unauthorized +from zExceptions import Forbidden, Unauthorized, NotFound -from zope.interface import implements, providedBy +from zope.interface import implements, providedBy, Interface from zope.component import queryMultiAdapter from zope.component import getSiteManager from zope.component.interfaces import ComponentLookupError @@ -26,7 +26,6 @@ from
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py Now uses adapters for __browser_default__ as well.
Log message for revision 67622: Now uses adapters for __browser_default__ as well. Changed: U Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-26 15:22:50 UTC (rev 67621) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-26 17:34:06 UTC (rev 67622) @@ -24,6 +24,7 @@ from zope.app.publication.interfaces import EndRequestEvent from zope.publisher.interfaces import IPublishTraverse from zope.publisher.interfaces import NotFound +from zope.publisher.interfaces.browser import IBrowserPublisher from zope.app.traversing.interfaces import TraversalError from zope.app.traversing.namespace import nsParse from zope.app.traversing.namespace import namespaceLookup @@ -54,21 +55,21 @@ class DefaultPublishTraverse(object): -implements(IPublishTraverse) +implements(IBrowserPublisher) def __init__(self, context, request): self.context = context self.request = request -def publishTraverse(self, name): +def publishTraverse(self, request, name): object = self.context -URL=self.request['URL'] +URL=request['URL'] if name[:1]=='_': raise Forbidden(Object name begins with an underscore at: %s % URL) if hasattr(object,'__bobo_traverse__'): -subobject=object.__bobo_traverse__(self.request, name) +subobject=object.__bobo_traverse__(request, name) if type(subobject) is type(()) and len(subobject) 1: # Add additional parents into the path parents[-1:] = list(subobject[:-1]) @@ -104,6 +105,11 @@ ) return subobject + +def browserDefault(self, request): +if hasattr(self.context, '__browser_default__'): +return self.context.__browser_default__(request) +return self.context, () _marker=[] @@ -264,14 +270,13 @@ if IPublishTraverse.providedBy(ob): ob2 = ob.publishTraverse(self, nm) else: -# self is marker adapter = queryMultiAdapter((ob, self), IPublishTraverse) if adapter is None: ## Zope2 doesn't set up its own adapters in a lot of cases ## so we will just use a default adapter. adapter = DefaultPublishTraverse(ob, self) -ob2 = adapter.publishTraverse(nm) +ob2 = adapter.publishTraverse(self, nm) return ob2 @@ -368,37 +373,48 @@ path = request.path = request['TraversalRequestNameStack'] # Check for method: if path: -entry_name = path.pop() -elif hasattr(object, '__browser_default__'): -# If we have reached the end of the path. We look to see -# if the object implements __browser_default__. If so, we -# call it to let the object tell us how to publish it -# __browser_default__ returns the object to be published +entry_name = path.pop() +else: +# If we have reached the end of the path, we look to see +# if we can find IBrowserPublisher.browserDefault. If so, +# we call it to let the object tell us how to publish it +# BrowserDefault returns the object to be published # (usually self) and a sequence of names to traverse to -# find the method to be published. (Casey) -request._hacked_path=1 -object, default_path = object.__browser_default__(request) -if len(default_path) 1: -path = list(default_path) -method = path.pop() -request['TraversalRequestNameStack'] = path -continue +# find the method to be published. +if IBrowserPublisher.providedBy(object): +adapter = object else: -entry_name = default_path[0] -elif (method and hasattr(object,method) - and entry_name != method - and getattr(object, method) is not None): -request._hacked_path=1 -entry_name = method -method = 'index_html' -else: -if (hasattr(object, '__call__')): -self.roles = getRoles(object, '__call__', object.__call__, -
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ Using a new ITraversalRequest adapter to adapt the Zope2 requests.traversal method to
Log message for revision 67200: Using a new ITraversalRequest adapter to adapt the Zope2 requests.traversal method to the Zope3 version. Changed: U Zope/branches/publication-refactor/lib/python/Products/Five/configure.zcml U Zope/branches/publication-refactor/lib/python/Products/Five/interfaces.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py -=- Modified: Zope/branches/publication-refactor/lib/python/Products/Five/configure.zcml === --- Zope/branches/publication-refactor/lib/python/Products/Five/configure.zcml 2006-04-21 09:38:13 UTC (rev 67199) +++ Zope/branches/publication-refactor/lib/python/Products/Five/configure.zcml 2006-04-21 09:51:55 UTC (rev 67200) @@ -50,5 +50,14 @@ five:implements class=ZPublisher.HTTPRequest.HTTPRequest interface=zope.publisher.interfaces.browser.IBrowserRequest / + + five:implements class=ZPublisher.HTTPRequest.HTTPRequest + interface=.interfaces.IZope2Request + / + adapter + for=.interfaces.IZope2Request + factory=ZPublisher.Publication.Zope3HTTPRequestTraverser + provides=zope.publisher.interfaces.ITraversingRequest + / /configure Modified: Zope/branches/publication-refactor/lib/python/Products/Five/interfaces.py === --- Zope/branches/publication-refactor/lib/python/Products/Five/interfaces.py 2006-04-21 09:38:13 UTC (rev 67199) +++ Zope/branches/publication-refactor/lib/python/Products/Five/interfaces.py 2006-04-21 09:51:55 UTC (rev 67200) @@ -27,6 +27,10 @@ find the method to be published. +class IZope2Request(Interface): +Marks the Zope2 request +pass + class IMenuItemType(IInterface): Menu item type Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2006-04-21 09:38:13 UTC (rev 67199) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2006-04-21 09:51:55 UTC (rev 67200) @@ -49,7 +49,7 @@ _marker = object() class Zope3HTTPRequestTraverser(object): -implements(IPublisherRequest) +implements(zope.publisher.interfaces.ITraversingRequest) def __init__(self, request): self.request = request @@ -61,12 +61,7 @@ return self.request.traverse(path, self.request.response, self.request.publication.validated_hook) -## XXX - Five declares that HTTPRequest implements IPublisherRequest -## but in fact it doesn't, the traverse method API is all wrong. -## component.provideAdapter(Zope3HTTPRequestTraverser, (HTTPRequest,), -## IPublisherRequest) - class ZopePublication(object): Base Zope2 publication specification. @@ -229,7 +224,8 @@ sys.exc_info()[2], ) except: -return request.response.exception() +request.response.exception() +return request.response finally: self._abort() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PageTemplates/ A new test and a new fix.
Log message for revision 67246: A new test and a new fix. Changed: U Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py U Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py -=- Modified: Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py === --- Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py 2006-04-21 18:04:43 UTC (rev 67245) +++ Zope/trunk/lib/python/Products/PageTemplates/ZopePageTemplate.py 2006-04-21 18:10:19 UTC (rev 67246) @@ -134,6 +134,14 @@ self.ZBindings_edit(self._default_bindings) self.pt_edit(text, content_type, encoding) +def pt_render(self, namespace, source=False, sourceAnnotations=False, + showtal=False): +if namespace is None: +namespace = self.pt_getContext() +return super(ZopePageTemplate, self).pt_render(namespace, source, sourceAnnotations, + showtal) + + def pt_getEngine(self): return getEngine() Modified: Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py === --- Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2006-04-21 18:04:43 UTC (rev 67245) +++ Zope/trunk/lib/python/Products/PageTemplates/tests/testZopePageTemplate.py 2006-04-21 18:10:19 UTC (rev 67246) @@ -94,6 +94,12 @@ pt = self.app.pt1 self.assertEqual(pt(), self.result) +def testPtErrors(self): +request = self.app.REQUEST +self._addPT('pt1', text=self.text, REQUEST=request) +pt = self.app.pt1 +pt.pt_render(None, source=1) +self.assertEqual(pt.pt_errors(None), None) class DummyFileUpload: ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py Moved the roles checking outside the name traversal.
Log message for revision 67116: Moved the roles checking outside the name traversal. Changed: U Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-19 06:48:06 UTC (rev 67115) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-19 08:47:39 UTC (rev 67116) @@ -185,7 +185,6 @@ def traverseName(self, object, entry_name): -got = 0 URL=self['URL'] if entry_name[:1]=='_': raise Forbidden(Object name begins with an underscore at: %s % URL) @@ -200,7 +199,6 @@ try: subobject=getattr(object, entry_name) except AttributeError: -got=1 subobject=object[entry_name] # Ensure that the object has a docstring, or that the parent @@ -227,10 +225,6 @@ The object at %s is not publishable. % URL ) -self.roles = getRoles( -object, (not got) and entry_name or None, subobject, -self.roles) -print self.roles return subobject @@ -362,7 +356,17 @@ request['URL'] = URL = '%s/%s' % (request['URL'], step) try: -object = self.traverseName(object, entry_name) +subobject = self.traverseName(object, entry_name) +if (hasattr(object,'__bobo_traverse__') or +hasattr(object, entry_name)): +check_name = entry_name +else: +check_name = None + +self.roles = getRoles( +object, check_name, subobject, +self.roles) +object = subobject except (KeyError, AttributeError): if response.debug_mode: return response.debugError( ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/ A branch to replace use Zope3 trabersal as main traversal.
Log message for revision 67077: A branch to replace use Zope3 trabersal as main traversal. Changed: A Zope/branches/easter-sprint_traversal-refactor/ U Zope/branches/easter-sprint_traversal-refactor/lib/python/AccessControl/Role.py -=- Copied: Zope/branches/easter-sprint_traversal-refactor (from rev 67076, Zope/trunk) Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/AccessControl/Role.py === --- Zope/trunk/lib/python/AccessControl/Role.py 2006-04-18 10:22:53 UTC (rev 67076) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/AccessControl/Role.py 2006-04-18 16:10:45 UTC (rev 67077) @@ -474,7 +474,7 @@ if submit=='Add Role': role=reqattr(REQUEST, 'role') -return self._addRole(role, REQUEST) +return self._addRole(role.strip(), REQUEST) if submit=='Delete Role': roles=reqattr(REQUEST, 'roles') ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py Step 1: Refactoring the traversl into something less monolithic.
Log message for revision 67081: Step 1: Refactoring the traversl into something less monolithic. Changed: U Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py -=- Modified: Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-18 16:48:55 UTC (rev 67080) +++ Zope/branches/easter-sprint_traversal-refactor/lib/python/ZPublisher/BaseRequest.py 2006-04-18 17:55:23 UTC (rev 67081) @@ -16,7 +16,7 @@ from urllib import quote import xmlrpc -from zExceptions import Forbidden +from zExceptions import Forbidden, Unauthorized from zope.event import notify from zope.app.publication.interfaces import EndRequestEvent @@ -184,6 +184,56 @@ __repr__=__str__ +def traverseName(self, object, entry_name): +got = 0 +URL=self['URL'] +if entry_name[:1]=='_': +raise Forbidden(Object name begins with an underscore at: %s % URL) + +if hasattr(object,'__bobo_traverse__'): +subobject=object.__bobo_traverse__(self,entry_name) +if type(subobject) is type(()) and len(subobject) 1: +# Add additional parents into the path +parents[-1:] = list(subobject[:-1]) +object, subobject = subobject[-2:] +else: +try: +subobject=getattr(object, entry_name) +except AttributeError: +got=1 +subobject=object[entry_name] + +# Ensure that the object has a docstring, or that the parent +# object has a pseudo-docstring for the object. Objects that +# have an empty or missing docstring are not published. +doc = getattr(subobject, '__doc__', None) +if doc is None: +doc = getattr(object, '%s__doc__' % entry_name, None) +if not doc: +raise Forbidden( +The object at %s has an empty or missing \ +docstring. Objects must have a docstring to be \ +published. % URL +) + +# Hack for security: in Python 2.2.2, most built-in types +# gained docstrings that they didn't have before. That caused +# certain mutable types (dicts, lists) to become publishable +# when they shouldn't be. The following check makes sure that +# the right thing happens in both 2.2.2+ and earlier versions. + +if not typeCheck(subobject): +raise Forbidden( +The object at %s is not publishable. % URL +) + +self.roles = getRoles( +object, (not got) and entry_name or None, subobject, +self.roles) +print self.roles +return subobject + + def traverse(self, path, response=None, validated_hook=None): Traverse the object space @@ -193,7 +243,6 @@ request=self request_get=request.get if response is None: response=self.response -debug_mode=response.debug_mode # remember path for later use browser_path = path @@ -235,14 +284,14 @@ object=parents[-1] del parents[:] -roles = getRoles(None, None, object, UNSPECIFIED_ROLES) +self.roles = getRoles(None, None, object, UNSPECIFIED_ROLES) # if the top object has a __bobo_traverse__ method, then use it # to possibly traverse to an alternate top-level object. if hasattr(object,'__bobo_traverse__'): try: object=object.__bobo_traverse__(request) -roles = getRoles(None, None, object, UNSPECIFIED_ROLES) +self.roles = getRoles(None, None, object, UNSPECIFIED_ROLES) except: pass if not path and not method: @@ -302,8 +351,8 @@ method = 'index_html' else: if (hasattr(object, '__call__')): -roles = getRoles(object, '__call__', object.__call__, - roles) +self.roles = getRoles(object, '__call__', object.__call__, + self.roles) if request._hacked_path: i=URL.rfind('/') if i 0: response.setBase(URL[:i]) @@ -311,91 +360,45 @@ step = quote(entry_name) _steps.append(step) request['URL'] = URL = '%s/%s' % (request['URL'], step) -got = 0 -if entry_name[:1]=='_': -if debug_mode: + +try: +object = self.traverseName(object, entry_name) +except (KeyError, AttributeError): +if response.debug_mode:
[Zope-Checkins] SVN: Products.Five/branches/1.3/ Made sure LocalizerLanguages class normalized language codes to xx-yy.
Log message for revision 66790: Made sure LocalizerLanguages class normalized language codes to xx-yy. Changed: U Products.Five/branches/1.3/CHANGES.txt U Products.Five/branches/1.3/i18n.py -=- Modified: Products.Five/branches/1.3/CHANGES.txt === --- Products.Five/branches/1.3/CHANGES.txt 2006-04-10 15:14:43 UTC (rev 66789) +++ Products.Five/branches/1.3/CHANGES.txt 2006-04-10 15:21:47 UTC (rev 66790) @@ -2,6 +2,12 @@ Five Changes +Five 1.3.5 (unreleased) +=== + +* Made sure LocalizerLanguages class normalized language codes to xx-yy, instead of + xx_YY or xx-YY. + Five 1.3.4 (2006-03-31) === Modified: Products.Five/branches/1.3/i18n.py === --- Products.Five/branches/1.3/i18n.py 2006-04-10 15:14:43 UTC (rev 66789) +++ Products.Five/branches/1.3/i18n.py 2006-04-10 15:21:47 UTC (rev 66790) @@ -19,6 +19,7 @@ from zope.interface import implements from zope.i18n import interpolate from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages +from zope.i18n.negotiator import normalize_lang from zope.app import zapi from zope.publisher.browser import BrowserLanguages @@ -71,7 +72,9 @@ accept_language = self.context.AcceptLanguage langs = [] for lang, node in accept_language.children.items(): -langs.append((node.get_quality(), lang)) +# Localizer may use xx_YY and xx-YY as language codes, +# while Zope expect xx-yy only, so we normalize the code here. +langs.append((node.get_quality(), normalize_lang(lang))) langs.extend([(n.get_quality(), l) for l, n in node.children.items()]) langs.sort() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/1.4/ Made sure LocalizerLanguages class normalized language codes to xx-yy.
Log message for revision 66791: Made sure LocalizerLanguages class normalized language codes to xx-yy. Changed: U Products.Five/branches/1.4/CHANGES.txt U Products.Five/branches/1.4/i18n.py -=- Modified: Products.Five/branches/1.4/CHANGES.txt === --- Products.Five/branches/1.4/CHANGES.txt 2006-04-10 15:21:47 UTC (rev 66790) +++ Products.Five/branches/1.4/CHANGES.txt 2006-04-10 15:25:56 UTC (rev 66791) @@ -2,6 +2,12 @@ Five Changes +Five 1.4.0 (unreleased) +=== + +* Made sure LocalizerLanguages class normalized language codes to xx-yy, instead of + xx_YY or xx-YY. + Five 1.4b (2006-03-31) == Modified: Products.Five/branches/1.4/i18n.py === --- Products.Five/branches/1.4/i18n.py 2006-04-10 15:21:47 UTC (rev 66790) +++ Products.Five/branches/1.4/i18n.py 2006-04-10 15:25:56 UTC (rev 66791) @@ -19,6 +19,7 @@ from zope.interface import implements from zope.i18n import interpolate from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages +from zope.i18n.negotiator import normalize_lang from zope.app import zapi from zope.publisher.browser import BrowserLanguages @@ -71,7 +72,9 @@ accept_language = self.context.AcceptLanguage langs = [] for lang, node in accept_language.children.items(): -langs.append((node.get_quality(), lang)) +# Localizer may use xx_YY and xx-YY as language codes, +# while Zope expect xx-yy only, so we normalize the code here. +langs.append((node.get_quality(), normalize_lang(lang))) langs.extend([(n.get_quality(), l) for l, n in node.children.items()]) langs.sort() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/trunk/ Made sure LocalizerLanguages class normalized language codes to xx-yy.
Log message for revision 66792: Made sure LocalizerLanguages class normalized language codes to xx-yy. Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/i18n.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-04-10 15:25:56 UTC (rev 66791) +++ Products.Five/trunk/CHANGES.txt 2006-04-10 15:28:07 UTC (rev 66792) @@ -2,6 +2,12 @@ Five Changes +Trunk (unreleased) +=== + +* Made sure LocalizerLanguages class normalized language codes to xx-yy, instead of + xx_YY or xx-YY. + Five 1.4b (2006-03-31) == Modified: Products.Five/trunk/i18n.py === --- Products.Five/trunk/i18n.py 2006-04-10 15:25:56 UTC (rev 66791) +++ Products.Five/trunk/i18n.py 2006-04-10 15:28:07 UTC (rev 66792) @@ -19,6 +19,7 @@ from zope.interface import implements from zope.i18n import interpolate from zope.i18n.interfaces import ITranslationDomain, IUserPreferredLanguages +from zope.i18n.negotiator import normalize_lang from zope.app import zapi from zope.publisher.browser import BrowserLanguages @@ -71,7 +72,9 @@ accept_language = self.context.AcceptLanguage langs = [] for lang, node in accept_language.children.items(): -langs.append((node.get_quality(), lang)) +# Localizer may use xx_YY and xx-YY as language codes, +# while Zope expect xx-yy only, so we normalize the code here. +langs.append((node.get_quality(), normalize_lang(lang))) langs.extend([(n.get_quality(), l) for l, n in node.children.items()]) langs.sort() ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/tags/regebro-cncc/ Just cleaning away an old tag.
Log message for revision 65496: Just cleaning away an old tag. Changed: D Products.Five/tags/regebro-cncc/ -=- ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/branches/regebro-localutility-fix/site/utility.py The old tests would have done the wrong thing if we had utilities named foo and
Log message for revision 65498: The old tests would have done the wrong thing if we had utilities named foo and superfoo. Changed: U Products.Five/branches/regebro-localutility-fix/site/utility.py -=- Modified: Products.Five/branches/regebro-localutility-fix/site/utility.py === --- Products.Five/branches/regebro-localutility-fix/site/utility.py 2006-02-26 20:31:28 UTC (rev 65497) +++ Products.Five/branches/regebro-localutility-fix/site/utility.py 2006-02-26 20:35:07 UTC (rev 65498) @@ -53,8 +53,12 @@ if getattr(aq_base(self.context), 'utilities', None) is not None: for id, utility in self.context.utilities.objectItems(): -if (interface.providedBy(utility) and -(name == '' or id.endswith(name))): +if interface.providedBy(utility): +if id.find('-') != -1: +prefix, utility_name = id.split('-', 1) +else: +utility_name = '' +if name == utility_name: return utility return self.next.queryUtility(interface, name, default) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Products.Five/trunk/ svn merge -r65405:65496 from branches/regebro-localutility-fix.
Log message for revision 65499: svn merge -r65405:65496 from branches/regebro-localutility-fix. * A local utility registered with an derived interface will now be available by the inherited interface as well, in the same way as Zope3. Changed: U Products.Five/trunk/CHANGES.txt U Products.Five/trunk/site/tests/test_utility.py U Products.Five/trunk/site/utility.py -=- Modified: Products.Five/trunk/CHANGES.txt === --- Products.Five/trunk/CHANGES.txt 2006-02-26 20:35:07 UTC (rev 65498) +++ Products.Five/trunk/CHANGES.txt 2006-02-26 20:45:08 UTC (rev 65499) @@ -23,6 +23,12 @@ NOTE: Anyone who copied the Five site.zcml to their $INSTANCE_HOME/etc/ directory is going to need to update it. +Bugfixes + + +* A local utility registered with an derived interface will now be available + by the inherited interface as well, in the same way as Zope3. + Five 1.3.2 (2006-02-25) === @@ -33,7 +39,7 @@ When no Zope 3-style view is found, first the object's original ``__bobo_traverse__`` is tried. If that does not exist, Traversable resorts to attribute look-up. - + * Unit tests that did i18n via Localizer would fail because the request attribute that keeps Localizers list of preferred languages did not exist. Modified: Products.Five/trunk/site/tests/test_utility.py === --- Products.Five/trunk/site/tests/test_utility.py 2006-02-26 20:35:07 UTC (rev 65498) +++ Products.Five/trunk/site/tests/test_utility.py 2006-02-26 20:45:08 UTC (rev 65499) @@ -81,7 +81,7 @@ def test_getUtilitiesNoUtilitiesFolder(self): sm = zapi.getSiteManager() -#XXX test whether sm really is a local site... + self.failUnless(sm.queryUtility(IDummyUtility) is None) self.assertEquals(list(sm.getUtilitiesFor(IDummyUtility)), []) self.assertEquals(list(sm.getAllUtilitiesRegisteredFor(IDummyUtility)), []) @@ -122,6 +122,49 @@ self.assertEquals(zapi.getUtility(ISuperDummyUtility, 'dummy'), superdummy) +def test_derivedInterfaceRegistration(self): +# Utilities providing a derived interface should be listed +# when you ask for an interface. So ask for IDummmyInterace, and +# anything registered for IDummyInterface of ISuperDummyInterface +# should come back. + +sm = zapi.getSiteManager() +self.failUnless(IRegisterUtilitySimply.providedBy(sm)) +dummy = DummyUtility() +superdummy = DummyUtility() +directlyProvides(superdummy, ISuperDummyUtility) +uts = list(sm.getUtilitiesFor(IDummyUtility)) +self.failUnlessEqual(uts, []) + +sm.registerUtility(ISuperDummyUtility, superdummy) + +# We should be able to access this utility both with +# IDummyUtility and ISuperDummyUtility interfaces: +uts = list(sm.getUtilitiesFor(IDummyUtility)) +self.failUnless(uts[0][1].aq_base is superdummy) +uts = list(sm.getUtilitiesFor(ISuperDummyUtility)) +self.failUnless(uts[0][1].aq_base is superdummy) + +# Also try that the standard zapi call works: +ut = zapi.getUtility(IDummyUtility, context=self.folder.site) +self.failUnless(ut.aq_base is superdummy) +ut = zapi.getUtility(ISuperDummyUtility, context=self.folder.site) +self.failUnless(ut.aq_base is superdummy) + +# If we register a second utility we should find both utilities +# when looking for the base interface +sm.registerUtility(IDummyUtility, dummy) + +uts = list(sm.getAllUtilitiesRegisteredFor(IDummyUtility)) +self.failUnless(dummy in uts) +self.failUnless(superdummy in uts) + +# But we should find only one when looking for the derived interface +uts = list(sm.getAllUtilitiesRegisteredFor(ISuperDummyUtility)) +self.failUnless(dummy not in uts) +self.failUnless(superdummy in uts) + + def test_nestedSitesDontConflictButStillAcquire(self): # let's register a dummy utility in the dummy site dummy = DummyUtility() Modified: Products.Five/trunk/site/utility.py === --- Products.Five/trunk/site/utility.py 2006-02-26 20:35:07 UTC (rev 65498) +++ Products.Five/trunk/site/utility.py 2006-02-26 20:45:08 UTC (rev 65499) @@ -51,29 +51,22 @@ def queryUtility(self, interface, name='', default=None): See IFiveUtilityRegistry interface -if name == '': -# Singletons. Only one per interface allowed, so, let's call it -# by the interface. -id = interface.getName() -else: -id = interface.getName() + '-' + name - if getattr(aq_base(self.context), 'utilities',