[Zope-Checkins] SVN: Zope/trunk/ deprecated OFS.content_types
Log message for revision 40762: deprecated OFS.content_types Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/App/ImageFile.py U Zope/trunk/lib/python/OFS/DTMLDocument.py U Zope/trunk/lib/python/OFS/DTMLMethod.py U Zope/trunk/lib/python/OFS/Image.py U Zope/trunk/lib/python/OFS/content_types.py U Zope/trunk/lib/python/ZClasses/Method.py U Zope/trunk/lib/python/webdav/NullResource.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/doc/CHANGES.txt 2005-12-13 07:30:22 UTC (rev 40762) @@ -26,6 +26,9 @@ Features added + - deprecated OFS.content_types (to be removed in Zope 2.11) and +replaced all occurences with zope.app.content_types + - OFS.content_types: moved code to zope.app.content_types and added method aliases Modified: Zope/trunk/lib/python/App/ImageFile.py === --- Zope/trunk/lib/python/App/ImageFile.py 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/App/ImageFile.py 2005-12-13 07:30:22 UTC (rev 40762) @@ -17,16 +17,17 @@ import os import time +import Acquisition +import Globals from Globals import InitializeClass from AccessControl import ClassSecurityInfo from App.config import getConfiguration -from OFS.content_types import guess_content_type from Globals import package_home from Common import rfc1123_date from DateTime import DateTime -import Acquisition -import Globals +from zope.app.content_types import guess_content_type + class ImageFile(Acquisition.Explicit): """Image objects stored in external files.""" Modified: Zope/trunk/lib/python/OFS/DTMLDocument.py === --- Zope/trunk/lib/python/OFS/DTMLDocument.py 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/OFS/DTMLDocument.py 2005-12-13 07:30:22 UTC (rev 40762) @@ -17,7 +17,7 @@ from Globals import InitializeClass from ZPublisher.Converters import type_converters from Globals import HTML, DTMLFile, MessageDialog -from OFS.content_types import guess_content_type +from zope.app.content_types import guess_content_type from DTMLMethod import DTMLMethod, decapitate from PropertyManager import PropertyManager from webdav.common import rfc1123_date Modified: Zope/trunk/lib/python/OFS/DTMLMethod.py === --- Zope/trunk/lib/python/OFS/DTMLMethod.py 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/OFS/DTMLMethod.py 2005-12-13 07:30:22 UTC (rev 40762) @@ -18,7 +18,7 @@ from Globals import HTML, DTMLFile, MessageDialog from Globals import InitializeClass from SimpleItem import Item_w__name__, pretty_tb -from OFS.content_types import guess_content_type +from zope.app.content_types import guess_content_type from PropertyManager import PropertyManager from AccessControl import ClassSecurityInfo from AccessControl.Role import RoleManager Modified: Zope/trunk/lib/python/OFS/Image.py === --- Zope/trunk/lib/python/OFS/Image.py 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/OFS/Image.py 2005-12-13 07:30:22 UTC (rev 40762) @@ -15,7 +15,7 @@ $Id$ """ import struct -from OFS.content_types import guess_content_type +from zope.app.content_types import guess_content_type from Globals import DTMLFile from Globals import InitializeClass from PropertyManager import PropertyManager Modified: Zope/trunk/lib/python/OFS/content_types.py === --- Zope/trunk/lib/python/OFS/content_types.py 2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/OFS/content_types.py 2005-12-13 07:30:22 UTC (rev 40762) @@ -15,4 +15,10 @@ $Id$ """ +import warnings +warnings.warn('Using OFS.content_types is deprecated (will be removed in Zope ' + '2.11). Instead use zope.app.content_types.', + DeprecationWarning, + stacklevel=2) + from zope.app.content_types import text_type, guess_content_type, add_files Modified: Zope/trunk/lib/python/ZClasses/Method.py === --- Zope/trunk/lib/python/ZClasses/Method.py2005-12-13 07:14:42 UTC (rev 40761) +++ Zope/trunk/lib/python/ZClasses/Method.py2005-12-13 07:30:22 UTC (rev 40762) @@ -19,13 +19,13 @@ import ZClassOwner from AccessControl.PermissionMapping import aqwrap, PermissionMapper -import OFS.content_types from OFS.DTMLMethod import DTMLMethod from Products.PythonScripts.PythonScript import PythonScript from zExceptions import BadRequest import marshal from cgi import escape +from zope.app.content_types import guess_content_type _marker=[] class ZCl
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py - Inline before_publishing_traverse handling and then fire the event
Log message for revision 40757: - Inline before_publishing_traverse handling and then fire the event Changed: U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py -=- Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 21:07:07 UTC (rev 40756) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 21:23:59 UTC (rev 40757) @@ -20,8 +20,6 @@ from zope.publisher.interfaces import NotFound, IPublicationRequest from zope.app.publication.interfaces import EndRequestEvent from zope.app.publication.interfaces import BeforeTraverseEvent -from zope.app.publication.interfaces import IBeforeTraverseEvent -from zope.app.testing import ztapi from ZPublisher.Publish import Retry from ZPublisher.Publish import get_module_info, call_object @@ -59,8 +57,12 @@ self.transactions_manager.begin() def callTraversalHooks(self, request, ob): -# Call __before_publishing_traverse__ hooks the Zope 3-way by -# firing an event. +# Call __before_publishing_traverse__ hooks +bpth = getattr(ob, '__before_publishing_traverse__', None) +if bpth is not None: +bpth(ob, request) + +# And then fire an event notify(BeforeTraverseEvent(ob, request)) def afterTraversal(self, request, ob): @@ -219,14 +221,3 @@ _publications[module_name] = ZopePublication(db=None, module_name=module_name) return _publications[module_name] - -def bptSubscriber(event): -ob = event.object -request = event.request -bpth = getattr(ob, '__before_publishing_traverse__', None) -if bpth is not None: -bpth(ob, request) - -# XXX Move to zcml. -ztapi.subscribe([IBeforeTraverseEvent], None, bptSubscriber) - ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/ OFS ObjectManager: Fixed list_imports() to tolerate missing
Log message for revision 40756: OFS ObjectManager: Fixed list_imports() to tolerate missing import directories. (Merged from trunk.) Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/OFS/ObjectManager.py U Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 21:05:33 UTC (rev 40755) +++ Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 21:07:07 UTC (rev 40756) @@ -27,6 +27,9 @@ Bugs fixed + - OFS ObjectManager: Fixed list_imports() to tolerate missing + import directories. + - Collector #1965: 'get_transaction' missing from builtins without sufficient deprecation notice (ZODB 3.6 properly removed it, but Zope needs to keep it for another release). Modified: Zope/branches/2.9/lib/python/OFS/ObjectManager.py === --- Zope/branches/2.9/lib/python/OFS/ObjectManager.py 2005-12-12 21:05:33 UTC (rev 40755) +++ Zope/branches/2.9/lib/python/OFS/ObjectManager.py 2005-12-12 21:07:07 UTC (rev 40756) @@ -619,6 +619,8 @@ paths.append(cfg.instancehome) for impath in paths: directory = os.path.join(impath, 'import') +if not os.path.isdir(directory): +continue listing += [f for f in os.listdir(directory) if f.endswith('.zexp') or f.endswith('.xml')] return listing Modified: Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py === --- Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2005-12-12 21:05:33 UTC (rev 40755) +++ Zope/branches/2.9/lib/python/OFS/tests/testObjectManager.py 2005-12-12 21:07:07 UTC (rev 40756) @@ -108,7 +108,6 @@ self.assertEqual( si.__ac_local_roles__, None ) def test_setObject_set_owner_with_emergency_user( self ): - om = self._makeOne() newSecurityManager( None, emergency_user ) @@ -380,6 +379,16 @@ self.assertRaises(BadRequest, om._setObject, 'REQUEST', si) self.assertRaises(BadRequest, om._setObject, '/', si) +def test_list_imports(self): +om = self._makeOne() +# This must work whether we've done "make instance" or not. +# So list_imports() may return an empty list, or whatever's +# in skel/import. Tolerate both cases. +self.failUnless(isinstance(om.list_imports(), list)) +for filename in om.list_imports(): +self.failUnless(filename.endswith('.zexp') or +filename.endswith('.xml')) + def test_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite( ObjectManagerTests ) ) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/ - Fixed a couple mistakes.
Log message for revision 40755: - Fixed a couple mistakes. - The ZPublisher tests now pass Changed: U Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py U Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPRequest.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py U Zope/branches/publication-refactor/lib/python/ZPublisher/tests/testPublish.py -=- Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 20:55:46 UTC (rev 40754) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 21:05:33 UTC (rev 40755) @@ -81,8 +81,13 @@ if other is None: other=kw else: other.update(kw) self.other = other -# Publication will be set by ZPublisher.Publish, publish(). -self.publication = None +self.environ = {} +# Publication will be overriden by ZPublisher.Publish, +# publish(), we assume that by default it's the "Zope2" +# module. This is done so that tests using BaseRequest +# directly don't break. +from ZPublisher.Publication import get_publication +self.publication = get_publication(module_name="Zope2") def setPublication(self, publication): self.publication = publication @@ -238,11 +243,15 @@ URL=request['URL'] parents = request['PARENTS'] +object = parents[-1] del parents[:] if not path and not method: return response.forbiddenError(self['URL']) +if self.publication.root is not object: +self.publication.root = object + object = self.publication.getApplication(self) roles = getRoles(None, None, object, UNSPECIFIED_ROLES) parents.append(object) Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPRequest.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPRequest.py 2005-12-12 20:55:46 UTC (rev 40754) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/HTTPRequest.py 2005-12-12 21:05:33 UTC (rev 40755) @@ -239,6 +239,8 @@ return self._client_addr def __init__(self, stdin, environ, response, clean=0): +# Call base class __init__. +BaseRequest.__init__(self, RESPONSE=response) self._orig_env=environ # Avoid the overhead of scrubbing the environment in the # case of request cloning for traversal purposes. If the @@ -256,7 +258,7 @@ have_env=environ.has_key get_env=environ.get self.response=response -other=self.other={'RESPONSE': response} +other = self.other self.form={} self.taintedform={} self.steps=[] Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 20:55:46 UTC (rev 40754) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 21:05:33 UTC (rev 40755) @@ -12,6 +12,7 @@ ## __version__='$Revision$'[11:-2] +import sys import transaction from zope.event import notify from zope.interface import implements @@ -19,6 +20,8 @@ from zope.publisher.interfaces import NotFound, IPublicationRequest from zope.app.publication.interfaces import EndRequestEvent from zope.app.publication.interfaces import BeforeTraverseEvent +from zope.app.publication.interfaces import IBeforeTraverseEvent +from zope.app.testing import ztapi from ZPublisher.Publish import Retry from ZPublisher.Publish import get_module_info, call_object @@ -42,7 +45,7 @@ # Fetch module info to be backwards compatible with 'bobo' # and Zope 2. (self.bobo_before, self.bobo_after, - self.application, self.realm, self.debug_mode, + self.root, self.realm, self.debug_mode, self.err_hook, self.validated_hook, self.transactions_manager) = get_module_info(self.module_name) @@ -72,7 +75,7 @@ def getApplication(self, request): # Return the application object for the given module. -ob = self.application +ob = self.root # Now, some code from ZPublisher.BaseRequest: # If the top object has a __bobo_traverse__ method, then use it @@ -151,9 +154,9 @@ except Retry: if not retry_allowed: return self.err_hook(object, request, -
[Zope-Checkins] SVN: Zope/trunk/ Fixed OFS.ObjectManager list_import() to tolerate missing directories.
Log message for revision 40754: Fixed OFS.ObjectManager list_import() to tolerate missing directories. Changed: U Zope/trunk/doc/CHANGES.txt U Zope/trunk/lib/python/OFS/ObjectManager.py U Zope/trunk/lib/python/OFS/tests/testObjectManager.py -=- Modified: Zope/trunk/doc/CHANGES.txt === --- Zope/trunk/doc/CHANGES.txt 2005-12-12 20:42:18 UTC (rev 40753) +++ Zope/trunk/doc/CHANGES.txt 2005-12-12 20:55:46 UTC (rev 40754) @@ -115,6 +115,9 @@ Bugs Fixed + - OFS ObjectManager: Fixed list_imports() to tolerate missing +import directories. + - Collector #1621, 1894: Removed support for use of long-deprecated 'whrandom' module. Modified: Zope/trunk/lib/python/OFS/ObjectManager.py === --- Zope/trunk/lib/python/OFS/ObjectManager.py 2005-12-12 20:42:18 UTC (rev 40753) +++ Zope/trunk/lib/python/OFS/ObjectManager.py 2005-12-12 20:55:46 UTC (rev 40754) @@ -625,6 +625,8 @@ paths.append(cfg.instancehome) for impath in paths: directory = os.path.join(impath, 'import') +if not os.path.isdir(directory): +continue listing += [f for f in os.listdir(directory) if f.endswith('.zexp') or f.endswith('.xml')] return listing Modified: Zope/trunk/lib/python/OFS/tests/testObjectManager.py === --- Zope/trunk/lib/python/OFS/tests/testObjectManager.py2005-12-12 20:42:18 UTC (rev 40753) +++ Zope/trunk/lib/python/OFS/tests/testObjectManager.py2005-12-12 20:55:46 UTC (rev 40754) @@ -108,7 +108,6 @@ self.assertEqual( si.__ac_local_roles__, None ) def test_setObject_set_owner_with_emergency_user( self ): - om = self._makeOne() newSecurityManager( None, emergency_user ) @@ -380,6 +379,16 @@ self.assertRaises(BadRequest, om._setObject, 'REQUEST', si) self.assertRaises(BadRequest, om._setObject, '/', si) +def test_list_imports(self): +om = self._makeOne() +# This must work whether we've done "make instance" or not. +# So list_imports() may return an empty list, or whatever's +# in skel/import. Tolerate both cases. +self.failUnless(isinstance(om.list_imports(), list)) +for filename in om.list_imports(): +self.failUnless(filename.endswith('.zexp') or +filename.endswith('.xml')) + def test_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite( ObjectManagerTests ) ) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/ - Fix a few minor typos. I can actually browse the ZMI now.
Log message for revision 40751: - Fix a few minor typos. I can actually browse the ZMI now. Changed: U Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py -=- Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 19:16:05 UTC (rev 40750) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 19:30:50 UTC (rev 40751) @@ -90,8 +90,8 @@ def close(self): self.other.clear() self._held = None +self.publication.endRequest(self, None) self.publication = None -self.publication.endRequest(self, None) def processInputs(self): """Do any input processing that could raise errors Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 19:16:05 UTC (rev 40750) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 19:30:50 UTC (rev 40751) @@ -16,7 +16,7 @@ from zope.event import notify from zope.interface import implements from zope.publisher.interfaces import IRequest, IPublication -from zope.publisher.interfaces import NotFound +from zope.publisher.interfaces import NotFound, IPublicationRequest from zope.app.publication.interfaces import EndRequestEvent from zope.app.publication.interfaces import BeforeTraverseEvent @@ -93,7 +93,18 @@ def callObject(self, request, ob): # Call the object the same way it's done in Zope 2. -return mapply(ob, request.getPositionalArguments(), + +# XXX Check if it's a Zope 3 or a Zope 2 request. Might not be +# true because someone (Five?) is saying that the Zope 2 +# request implements IPublicationRequest so we check for the +# method name. Yuck. +if (IPublicationRequest.providedBy(request) and +hasattr(request, 'getPositionalArguments')): +args = request.getPositionalArguments() +else: +# It's a Zope 2 request. +args = request.args +return mapply(ob, args, request, call_object, 1, missing_name, dont_publish_class, request, bind=1) Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py 2005-12-12 19:16:05 UTC (rev 40750) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py 2005-12-12 19:30:50 UTC (rev 40751) @@ -95,8 +95,9 @@ if publication.debug_mode: response.debug_mode = publication.debug_mode -if realm and not request.get('REMOTE_USER',None): +if publication.realm and not request.get('REMOTE_USER',None): response.realm = publication.realm +validated_hook = publication.validated_hook # Do any pre-traversal setup, like starting a new transaction. publication.beforeTraversal(request) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/ - Make Publish.py use the new IPublication object
Log message for revision 40750: - Make Publish.py use the new IPublication object Changed: U Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py -=- Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 18:57:23 UTC (rev 40749) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 19:16:05 UTC (rev 40750) @@ -20,7 +20,6 @@ from zope.publisher.interfaces import NotFound from zExceptions import Forbidden -from ZPublisher.Publication import get_publication UNSPECIFIED_ROLES='' @@ -81,9 +80,13 @@ """ if other is None: other=kw else: other.update(kw) -self.other=other -self.publication = get_publication() +self.other = other +# Publication will be set by ZPublisher.Publish, publish(). +self.publication = None +def setPublication(self, publication): +self.publication = publication + def close(self): self.other.clear() self._held = None Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 18:57:23 UTC (rev 40749) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 19:16:05 UTC (rev 40750) @@ -99,12 +99,9 @@ def afterCall(self, request, ob): # Last part of ZPublisher.Publish.{publish, publish_module_standard}, -# commit the transaction and call 'bobo_after' hook if one was -# provided. +# commit the transaction. if self.transactions_manager: self.transactions_manager.commit() -if self.bobo_after is not None: -self.bobo_after() def endRequest(self, request, ob): # End the request the Zope 3-way, by firing an event. @@ -122,11 +119,14 @@ if self.transactions_manager: self.transactions_manager.recordMetaData(ob, request) +def _abort(self): +if self.transactions_manager: +self.transactions_manager.abort() + def handleException(self, object, request, exc_info, retry_allowed=True): # Some exception handling from ZPublisher.Publish.publish(). if self.err_hook is None: -if transactions_manager: -transactions_manager.abort() +self._abort() raise # If an err_hook was registered, use it. @@ -145,8 +145,7 @@ exc_info[2], ) finally: -if self.transactions_manager: -self.transactions_manager.abort() +self._abort() # XXX After this code, in ZPublisher.Publish.publish(), Zope 2 # does a 'Retry' if a 'Retry' exception happens and the @@ -199,8 +198,10 @@ raise NotFound(ob, name) _publication = None -def get_publication(module_name): +def get_publication(module_name=None): global _publication +if module_name is None: +module_name = "Zope2" if _publication is None: -_publication = ZopePublication(db=None, module_name="Zope2") +_publication = ZopePublication(db=None, module_name=module_name) return _publication Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py 2005-12-12 18:57:23 UTC (rev 40749) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py 2005-12-12 19:16:05 UTC (rev 40750) @@ -59,67 +59,70 @@ _default_realm = realm def publish(request, module_name, after_list, debug=0, -# Optimize: +# Optimize (now unused). call_object=call_object, missing_name=missing_name, dont_publish_class=dont_publish_class, mapply=mapply, ): -(bobo_before, bobo_after, object, realm, debug_mode, err_hook, - validated_hook, transactions_manager)= get_module_info(module_name) +# We assume the publication object returned is the one in +# ZPublisher.Publication here so we don't bother using accessors +# and poke directly into the variables. +from ZPublisher.Publication import get_publication +publication = get_publication(module_name) +request.setPublication(publication) -parents=None -response=None +# BBB: bobo_after hooks are called from 'publi
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/ - Implemented traverseName method and changed BaseRequest to use a (singleton) publication object
Log message for revision 40746: - Implemented traverseName method and changed BaseRequest to use a (singleton) publication object Changed: U Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py -=- Modified: Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 18:50:08 UTC (rev 40745) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/BaseRequest.py 2005-12-12 18:50:34 UTC (rev 40746) @@ -14,13 +14,14 @@ $Id$ """ -from urllib import quote + import xmlrpc +from urllib import quote +from zope.publisher.interfaces import NotFound + from zExceptions import Forbidden +from ZPublisher.Publication import get_publication -from zope.event import notify -from zope.app.publication.interfaces import EndRequestEvent - UNSPECIFIED_ROLES='' try: @@ -81,11 +82,13 @@ if other is None: other=kw else: other.update(kw) self.other=other +self.publication = get_publication() def close(self): self.other.clear() -self._held=None -notify(EndRequestEvent(None, self)) +self._held = None +self.publication = None +self.publication.endRequest(self, None) def processInputs(self): """Do any input processing that could raise errors @@ -155,7 +158,7 @@ def __contains__(self, key): return self.has_key(key) - + def keys(self): keys = {} keys.update(self.common) @@ -231,28 +234,14 @@ no_acquire_flag=0 URL=request['URL'] -parents=request['PARENTS'] -object=parents[-1] +parents = request['PARENTS'] del parents[:] -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) -except: pass - if not path and not method: return response.forbiddenError(self['URL']) -# Traverse the URL to find the object: -if hasattr(object, '__of__'): -# Try to bind the top-level object to the request -# This is how you get 'self.REQUEST' -object=object.__of__(RequestContainer(REQUEST=request)) +object = self.publication.getApplication(self) +roles = getRoles(None, None, object, UNSPECIFIED_ROLES) parents.append(object) steps=self.steps @@ -270,9 +259,7 @@ # We build parents in the wrong order, so we # need to make sure we reverse it when we're doe. while 1: -bpth = getattr(object, '__before_publishing_traverse__', None) -if bpth is not None: -bpth(object, self) +self.publication.callTraversalHooks(self, object) path = request.path = request['TraversalRequestNameStack'] # Check for method: @@ -318,48 +305,16 @@ "Object name begins with an underscore at: %s" % URL) else: return response.forbiddenError(entry_name) -if hasattr(object,'__bobo_traverse__'): -try: -subobject=object.__bobo_traverse__(request,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:] -except (AttributeError, KeyError): -if debug_mode: -return response.debugError( -"Cannot locate object at: %s" % URL) -else: -return response.notFoundError(URL) -else: -try: -# Note - no_acquire_flag is necessary to support -# things like DAV. We have to make sure -# that the target object is not acquired -# if the request_method is other than GET -# or POST. Otherwise, you could never use -# PUT to add a new object named 'test' if -# an object 'test' existed above it in the -# heirarchy -- you'd always get the -# existing object :( +try: +
[Zope-Checkins] SVN: Zope/branches/publication-refactor/lib/python/ZPublisher/Publi - Checkpoint before I dig into refactoring BaseRequest.py and Publish.py
Log message for revision 40742: - Checkpoint before I dig into refactoring BaseRequest.py and Publish.py Changed: A Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py U Zope/branches/publication-refactor/lib/python/ZPublisher/Publish.py -=- Added: Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py === --- Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 17:59:17 UTC (rev 40741) +++ Zope/branches/publication-refactor/lib/python/ZPublisher/Publication.py 2005-12-12 18:10:07 UTC (rev 40742) @@ -0,0 +1,152 @@ +## +# +# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved. +# +# This software is subject to the provisions of the Zope Public License, +# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. +# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED +# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS +# FOR A PARTICULAR PURPOSE +# +## +__version__='$Revision$'[11:-2] + +import transaction +from zope.event import notify +from zope.interface import implements +from zope.publisher.interfaces import IRequest, IPublication +from zope.app.publication.interfaces import EndRequestEvent +from zope.app.publication.interfaces import BeforeTraverseEvent + +from ZPublisher.Publish import Retry +from ZPublisher.Publish import get_module_info, call_object +from ZPublisher.Publish import missing_name, dont_publish_class +from ZPublisher.mapply import mapply +from ZPublisher.BaseRequest import RequestContainer + +class ZopePublication(object): +"""Base Zope2 publication specification. +""" +implements(IPublication) + +module_name = "Zope2" + +def __init__(self, db): +# db is a ZODB.DB.DB object. +# XXX We don't use this yet. +self.db = db + +# Fetch module info the to be backwards compatible with 'bobo' +# and Zope 2. +(self.bobo_before, self.bobo_after, + self.application, self.realm, self.debug_mode, + self.err_hook, self.validated_hook, + self.transactions_manager) = get_module_info(self.module_name) + +def beforeTraversal(self, request): +# First part of old ZPublisher.Publish.publish. Call +# 'bobo_before' hooks and start a new transaction using the +# 'transaction_manager'. +if self.bobo_before is not None: +self.bobo_before() +if self.transactions_manager: +self.transactions_manager.begin() + +def callTraversalHooks(self, request, ob): +# Call __before_publishing_traverse__ hooks the Zope 3-way by +# firing an event. +notify(BeforeTraverseEvent(ob, request)) + +def afterTraversal(self, request, ob): +# XXX Authentication should happen here. It used to happen at +# the end of BaseRequest.traverse(). + +# Zope 2 does annotate the transaction just after traversal, +# but before calling the object. Zope 3 does annotate the +# transaction on afterCall instead. +txn = transaction.get() +self.annotateTransaction(txn, request, ob) + +def getApplication(self, request): +# Return the application object for the given module. +ob = self.application + +# Now, some code from ZPublisher.BaseRequest: +# If the top object has a __bobo_traverse__ method, then use it +# to possibly traverse to an alternate top-level object. +if hasattr(ob, '__bobo_traverse__'): +try: +ob = ob.__bobo_traverse__(request) +except: +# XXX Blind except? Yuck! +pass + +if hasattr(ob, '__of__'): +# Try to bind the top-level object to the request +# This is how you get 'self.REQUEST' +ob = ob.__of__(RequestContainer(REQUEST=request)) + +return ob + +def callObject(self, request, ob): +# Call the object the same way it's done in Zope 2. +return mapply(ob, request.getPositionalArguments(), + request, call_object, 1, missing_name, + dont_publish_class, request, bind=1) + +def afterCall(self, request, ob): +# Last part of ZPublisher.Publish.{publish, publish_module_standard}, +# commit the transaction and call 'bobo_after' hook if one was +# provided. +if self.transactions_manager: +self.transactions_manager.commit() +if self.bobo_after is not None: +self.bobo_after() + +def endRequest(self, request, ob): +# End the request the Zope 3-way,
[Zope-Checkins] SVN: Zope/branches/publication-refactor/ - Make a branch to refactor Zope 2 ZPublisher into a hybrid implementing Zope 3 IPublication
Log message for revision 40741: - Make a branch to refactor Zope 2 ZPublisher into a hybrid implementing Zope 3 IPublication Changed: A Zope/branches/publication-refactor/ -=- Copied: Zope/branches/publication-refactor (from rev 40740, Zope/trunk) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/doc/ Trivial doc fixes from trunk.
Log message for revision 40736: Trivial doc fixes from trunk. Changed: U Zope/branches/2.9/doc/FAQ.txt U Zope/branches/2.9/doc/INSTALL.txt -=- Modified: Zope/branches/2.9/doc/FAQ.txt === --- Zope/branches/2.9/doc/FAQ.txt 2005-12-12 16:31:56 UTC (rev 40735) +++ Zope/branches/2.9/doc/FAQ.txt 2005-12-12 16:36:13 UTC (rev 40736) @@ -277,15 +277,11 @@ browser. Clear your cache and view the HTML source again. -2. I'm using Python 2.4 and I'm having a problem ... +2. I'm using Python 2.x and I'm having a problem ... - As of the release of Zope 2.8, Python 2.4 has not been approved for - use with any version of Zope yet. Please use Python 2.3. - The correct version of Python should always be automatically detected and used when you configure and install Zope. In general, you should let the configure script do its job and don't try to force an unsupported version of Python! - Modified: Zope/branches/2.9/doc/INSTALL.txt === --- Zope/branches/2.9/doc/INSTALL.txt 2005-12-12 16:31:56 UTC (rev 40735) +++ Zope/branches/2.9/doc/INSTALL.txt 2005-12-12 16:36:13 UTC (rev 40736) @@ -181,7 +181,7 @@ Zope doesn't require any existing webserver to run, but you can integrate it with other webservers as necessary. See the - WEBSERVERS.txt file for more information about configuring Zope with + WEBSERVER.txt file for more information about configuring Zope with an existing web server. There is also information about integrating Zope with existing webservers on the Zope.org website. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/lib/python/Zope2/App/startup.py Add 'stacklevel=2' to deprecation warning to show call site.
Log message for revision 40733: Add 'stacklevel=2' to deprecation warning to show call site. Thanks to Tim Peters for pointing out the flaw! Changed: U Zope/branches/2.9/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py === --- Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 16:14:45 UTC (rev 40732) +++ Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 16:27:55 UTC (rev 40733) @@ -304,7 +304,8 @@ transaction.get().commit(), and transaction.abort() of transaction.get().abort(). """ -warnings.warn(_GET_TRANSACTION_DEPRECATED, DeprecationWarning) +warnings.warn(_GET_TRANSACTION_DEPRECATED, DeprecationWarning, + stacklevel=2) return transaction.get() import __builtin__ ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/doc/FAQ.txt Removed old instructions to avoid python 2.4.
Log message for revision 40732: Removed old instructions to avoid python 2.4. (Keeping the general instructions to let ./configure choose the right version of python for you.) Changed: U Zope/trunk/doc/FAQ.txt -=- Modified: Zope/trunk/doc/FAQ.txt === --- Zope/trunk/doc/FAQ.txt 2005-12-12 16:13:53 UTC (rev 40731) +++ Zope/trunk/doc/FAQ.txt 2005-12-12 16:14:45 UTC (rev 40732) @@ -277,15 +277,11 @@ browser. Clear your cache and view the HTML source again. -2. I'm using Python 2.4 and I'm having a problem ... +2. I'm using Python 2.x and I'm having a problem ... - As of the release of Zope 2.8, Python 2.4 has not been approved for - use with any version of Zope yet. Please use Python 2.3. - The correct version of Python should always be automatically detected and used when you configure and install Zope. In general, you should let the configure script do its job and don't try to force an unsupported version of Python! - ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/doc/INSTALL.txt Trivial typo, WEBSERVER.txt was misspelled.
Log message for revision 40731: Trivial typo, WEBSERVER.txt was misspelled. Changed: U Zope/trunk/doc/INSTALL.txt -=- Modified: Zope/trunk/doc/INSTALL.txt === --- Zope/trunk/doc/INSTALL.txt 2005-12-12 15:56:57 UTC (rev 40730) +++ Zope/trunk/doc/INSTALL.txt 2005-12-12 16:13:53 UTC (rev 40731) @@ -181,7 +181,7 @@ Zope doesn't require any existing webserver to run, but you can integrate it with other webservers as necessary. See the - WEBSERVERS.txt file for more information about configuring Zope with + WEBSERVER.txt file for more information about configuring Zope with an existing web server. There is also information about integrating Zope with existing webservers on the Zope.org website. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
Re: [Zope-Checkins] SVN: Zope/branches/2.9/ Collector #1965: 'get_transaction' missing from builtins without sufficient deprecation notice
[Tres Seaver] > Log message for revision 40728: > Collector #1965: 'get_transaction' missing from builtins without sufficient > deprecation notice > > o ZODB 3.6 properly removed it, but Zope needs to keep it for another release >because ZODB released *twice* during the Zope 2.9 release cycle. > > > Changed: > U Zope/branches/2.9/doc/CHANGES.txt > U Zope/branches/2.9/lib/python/Zope2/App/startup.py > > -=- ... > --- Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 14:55:28 > UTC (rev 40727) > +++ Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 15:06:09 > UTC (rev 40728) ... > +def get_transaction(): > +_GET_TRANSACTION_DEPRECATED = """\ > +The 'get_transaction' utility function in __builtin__ is deprecated, and > +will be removed in Zope 2.10 (May 2006). > + > +Please import the transaction module, and use transaction.get() instead of > +get_transaction(). transaction.commit() is a shortcut spelling of > +transaction.get().commit(), and transaction.abort() of > +transaction.get().abort(). > +""" > +warnings.warn(_GET_TRANSACTION_DEPRECATED, DeprecationWarning) Tres, you probably want to supply a stacklevel=2 argument here, so that the warning points to the code _calling_ get_transaction() instead of to the warnings.warn() line itself. ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/ Collector #1965: 'get_transaction' missing from builtins without sufficient deprecation notice
Log message for revision 40728: Collector #1965: 'get_transaction' missing from builtins without sufficient deprecation notice o ZODB 3.6 properly removed it, but Zope needs to keep it for another release because ZODB released *twice* during the Zope 2.9 release cycle. Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/lib/python/Zope2/App/startup.py -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 14:55:28 UTC (rev 40727) +++ Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 15:06:09 UTC (rev 40728) @@ -27,6 +27,10 @@ Bugs fixed + - Collector #1965: 'get_transaction' missing from builtins without + sufficient deprecation notice (ZODB 3.6 properly removed it, but + Zope needs to keep it for another release). + - Several zope.app packages were forgotten to be included in the first beta due to the now zpkg-based build and release process. Modified: Zope/branches/2.9/lib/python/Zope2/App/startup.py === --- Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 14:55:28 UTC (rev 40727) +++ Zope/branches/2.9/lib/python/Zope2/App/startup.py 2005-12-12 15:06:09 UTC (rev 40728) @@ -12,6 +12,7 @@ ## """Initialize the Zope2 Package and provide a published module """ +import warnings from AccessControl.SecurityManagement import getSecurityManager from AccessControl.SecurityManagement import newSecurityManager @@ -223,6 +224,7 @@ ac_logger = logging.getLogger('event.AccessControl') + class TransactionsManager: def begin(self, # Optimize global var lookups: @@ -290,4 +292,22 @@ T.setUser(auth_user.getId(), auth_path) +# BBB: older code expects 'get_transaction' to be available in __builtin__. +def get_transaction(): +_GET_TRANSACTION_DEPRECATED = """\ +The 'get_transaction' utility function in __builtin__ is deprecated, and +will be removed in Zope 2.10 (May 2006). + +Please import the transaction module, and use transaction.get() instead of +get_transaction(). transaction.commit() is a shortcut spelling of +transaction.get().commit(), and transaction.abort() of +transaction.get().abort(). +""" +warnings.warn(_GET_TRANSACTION_DEPRECATED, DeprecationWarning) +return transaction.get() + +import __builtin__ +__builtin__.get_transaction = get_transaction +del __builtin__ +del get_transaction ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/releases/Zope2/DEPENDENCIES.cfg Merge r40726 from 2.9 branch:
Log message for revision 40727: Merge r40726 from 2.9 branch: Several zope.app packages were forgotten to be included in the first beta due to the now zpkg-based build and release process. Changed: U Zope/trunk/releases/Zope2/DEPENDENCIES.cfg -=- Modified: Zope/trunk/releases/Zope2/DEPENDENCIES.cfg === --- Zope/trunk/releases/Zope2/DEPENDENCIES.cfg 2005-12-12 14:48:25 UTC (rev 40726) +++ Zope/trunk/releases/Zope2/DEPENDENCIES.cfg 2005-12-12 14:55:28 UTC (rev 40727) @@ -53,6 +53,15 @@ zLOG zope.app +zope.app.apidoc +zope.app.cache +zope.app.dtmlpage +zope.app.mail +zope.app.onlinehelp +zope.app.rdb +zope.app.sqlscript +zope.app.undo +zope.app.zptpage # zope.app depends for us on: # - ZODB ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.9/ Several zope.app packages were forgotten to be included in the
Log message for revision 40726: Several zope.app packages were forgotten to be included in the first beta due to the now zpkg-based build and release process. Changed: U Zope/branches/2.9/doc/CHANGES.txt U Zope/branches/2.9/releases/Zope2/DEPENDENCIES.cfg -=- Modified: Zope/branches/2.9/doc/CHANGES.txt === --- Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 14:18:05 UTC (rev 40725) +++ Zope/branches/2.9/doc/CHANGES.txt 2005-12-12 14:48:25 UTC (rev 40726) @@ -27,7 +27,8 @@ Bugs fixed - + - Several zope.app packages were forgotten to be included in the + first beta due to the now zpkg-based build and release process. Features added Modified: Zope/branches/2.9/releases/Zope2/DEPENDENCIES.cfg === --- Zope/branches/2.9/releases/Zope2/DEPENDENCIES.cfg 2005-12-12 14:18:05 UTC (rev 40725) +++ Zope/branches/2.9/releases/Zope2/DEPENDENCIES.cfg 2005-12-12 14:48:25 UTC (rev 40726) @@ -53,6 +53,15 @@ zLOG zope.app +zope.app.apidoc +zope.app.cache +zope.app.dtmlpage +zope.app.mail +zope.app.onlinehelp +zope.app.rdb +zope.app.sqlscript +zope.app.undo +zope.app.zptpage # zope.app depends for us on: # - ZODB ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins