[Zope3-checkins]
SVN: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/
Reviewed Tarek's and Andreas' work on the puggable
HTTP-subprotocol work.
Stephan Richter
srichter at cosmos.phy.tufts.edu
Tue Oct 11 18:46:44 EDT 2005
Log message for revision 39082:
Reviewed Tarek's and Andreas' work on the puggable HTTP-subprotocol work.
I like the final solution, especially having taken part in the design
discussions. While a priority-driven system might seem sub-optimal, it is
much saner than the alternative, which is to have huge complexity for a
task that needs to perform well.
In the code below I fixed some code to more common Zope 3 patterns.
Changed:
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/__init__.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/onlinehelp.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.txt
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metadirectives.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationfactories.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_httpfactory.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationfactories.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/testing/tests.py
U Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/wsgi/tests.py
-=-
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/__init__.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/__init__.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/__init__.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -13,7 +13,7 @@
##############################################################################
"""OnlineHelp System.
-Create the global `OnlineHelp` instance.
+Create the global `OnlineHelp` instance.
$Id$
"""
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/onlinehelp.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/onlinehelp.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/onlinehelp/onlinehelp.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -41,11 +41,11 @@
>>> path = os.path.join(testdir(), 'help.txt')
Create an `OnlineHelp` instance
-
+
>>> onlinehelp = OnlineHelp('Help', path)
First do the interface verifying tests.
-
+
>>> from zope.interface.verify import verifyObject
>>> from zope.app.traversing.interfaces import IContainmentRoot
>>> verifyObject(IOnlineHelp, onlinehelp)
@@ -126,8 +126,7 @@
if class_ is None:
class_ = OnlineHelpTopic
-
-
+
# Create topic base on the custom class or OnlinHelpTopic
topic = class_(id, title, doc_path, parent_path, interface, view)
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/configure.zcml 2005-10-11 22:46:43 UTC (rev 39082)
@@ -13,32 +13,32 @@
<publisher
name="SOAP"
factory=".requestpublicationfactories.SOAPFactory"
- method="POST"
- mimetype="text/xml"
+ methods="POST"
+ mimetypes="text/xml"
priority="30"
/>
<publisher
name="XMLRPC"
factory=".requestpublicationfactories.XMLRPCFactory"
- method="POST"
- mimetype="text/xml"
+ methods="POST"
+ mimetypes="text/xml"
priority="20"
/>
<publisher
name="BROWSER"
factory=".requestpublicationfactories.BrowserFactory"
- method="GET,POST,HEAD"
- mimetype="*"
+ methods="GET POST HEAD"
+ mimetypes="*"
priority="0"
/>
<publisher
name="HTTP"
factory=".requestpublicationfactories.HTTPFactory"
- method="*"
- mimetype="*"
+ methods="*"
+ mimetypes="*"
priority="0"
/>
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -23,13 +23,14 @@
from zope.app.publication import interfaces
from zope.app.publication.browser import setDefaultSkin
-from zope.app.publication.metaconfigure import getFactoryRegistry
+from zope.app.publication.requestpublicationregistry import factoryRegistry
def chooseClasses(method, environment):
-
+ """Given the method and environment, choose the correct request and
+ publication factort."""
content_type = environment.get('CONTENT_TYPE', '')
- factory = getFactoryRegistry().lookup(method, content_type, environment)
+ factory = factoryRegistry.lookup(method, content_type, environment)
request_class, publication = factory()
return request_class, publication
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.txt
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.txt 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/httpfactory.txt 2005-10-11 22:46:43 UTC (rev 39082)
@@ -1,5 +1,4 @@
-$Id:$
-
+=================
HTTPFactory tests
=================
@@ -9,7 +8,7 @@
The publication class is chosen upon the method name,
the mime type and sometimes some request headers
-A regular GET, POST or HEAD
+A regular GET, POST or HEAD
>>> print http(r"""
... GET / HTTP/1.1
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metaconfigure.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -19,58 +19,17 @@
"""
__docformat__ = 'restructuredtext'
-from zope.app.publication.requestpublicationregistry import RequestPublicationRegistry
+from zope.app.publication.requestpublicationregistry import factoryRegistry
-class RequestPublicationRegisterer(object):
- """ Link a request type to a request-publication factory """
+def publisher(_context, name, factory, methods=['*'], mimetypes=['*'],
+ priority=0):
- def __init__(self, name, factory, method=u'', mimetype=u'', priority=0):
+ factory = factory()
- methods = self._extractElements(method)
- mimetypes = self._extractElements(mimetype)
- self._installFactory(name, factory, methods, mimetypes, priority)
-
- def _extractElements(self, chain):
- """ elements are separated by commas,
- XXXX use schema.token
-
- >>> reg = RequestPublicationRegisterer()
- >>> reg._extractElements('GET, POST,HEAD')
- ['GET', 'POST', 'HEAD']
- >>> reg._extractElements('*')
- ['*']
- >>> reg._extractElements('')
- ['*']
- >>> reg._extractElements('text/xml, text/html')
- ['text/xml', 'text/html']
- """
- def _cleanElement(element):
- element = element.strip()
- if element == u'' or element is None:
- return u'*'
- return element
-
- return map(_cleanElement, chain.split(u','))
-
- def _installFactory(self, name, factory, methods, mimetypes, priority):
- """ calls the register factory utility, that actually links
- the factory.
- """
- registerer = getFactoryRegistry().register
-
- # need to register all methods<->mimetypes combos here
- # for imbrication: usally there are more methods than mimetypes
- for method in methods:
- for mimetype in mimetypes:
- registerer(method, mimetype, name, priority, factory)
-
-_factory_registerer = None
-
-def getFactoryRegistry():
- global _factory_registerer
- if _factory_registerer is None:
- _factory_registerer = RequestPublicationRegistry()
- return _factory_registerer
-
-def publisher(_context, name, factory, method='*', mimetype='*', priority=0):
- RequestPublicationRegisterer(name, factory(), method, mimetype, priority)
+ for method in methods:
+ for mimetype in mimetypes:
+ _context.action(
+ discriminator = (method, mimetype, priority),
+ callable = factoryRegistry.register,
+ args = (method, mimetype, name, priority, factory)
+ )
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metadirectives.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metadirectives.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/metadirectives.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -11,7 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
-""" Directive schema, for publication factory
+"""Directive schema, for publication factory
This module provides the schema for the new zcml directive,
that let the developer associate a publication factory to a given
@@ -27,35 +27,37 @@
__docformat__ = 'restructuredtext'
from zope.interface import Interface
-from zope.configuration.fields import GlobalObject
+from zope.configuration.fields import GlobalObject, Tokens
from zope.schema import TextLine, Int
class IRequestPublicationDirective(Interface):
- """ Link a request type to a request-publication factory """
+ """Link a request type to a request and publication factory"""
- name = TextLine(title=u'Name',
- description=u'The name of the publication factory.')
+ name = TextLine(
+ title=u'Name',
+ description=u'The name of the publication factory.')
- factory = GlobalObject(title=u'Factory',
- description=u'The request-publication factory')
+ factory = GlobalObject(
+ title=u'Factory',
+ description=u'The request-publication factory')
- method = TextLine(title=u'Method',
- description=(u'The name of the request method.'
- 'The method can be a "*" for'
- 'the publication to catch all method'
- 'otherwise, has to be one or many methods'
- 'all separated by commas: ie: "GET,POST"'),
- required=False)
+ methods = Tokens(
+ title=u'Methods',
+ description=(u'A list of HTTP method names. If the method is a "*", '
+ u'then all methods will match. Example: "GET POST"'),
+ value_type=TextLine(),
+ required=False)
- mimetype = TextLine(title=u'MimeType',
- description=(u'The content type of the request.'
- 'The method can be a "*" for'
- 'the publication to catch all method'
- 'otherwise, has to be one or many methods'
- 'all separated by commas: ie: "text/xml,text/html"'),
- required=False)
+ mimetypes = Tokens(
+ title=u'Mime Types',
+ description=(u'A list of content/mime types of the request. If the '
+ u'type is a "*" then all types will be matched. '
+ u'Example: "text/html text/xml"'),
+ value_type=TextLine(),
+ required=False)
- priority = Int(title=u'Priority',
- description=(u'A priority key used to concurrent'
- ' publication factories.'),
- required=False)
+ priority = Int(
+ title=u'Priority',
+ description=(u'A priority key used to concurrent'
+ ' publication factories.'),
+ required=False)
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationfactories.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationfactories.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationfactories.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -21,13 +21,13 @@
from zope import component
from zope.interface import implements
-from zope.app.publication.interfaces import IRequestPublicationFactory
+from zope.app.publication.interfaces import IRequestPublicationFactory
from zope.app.publication import interfaces
from zope.app.publication.soap import SOAPPublication
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.publication.http import HTTPPublication
from zope.publisher.xmlrpc import XMLRPCRequest
-from zope.app.publication.browser import BrowserPublication
+from zope.app.publication.browser import BrowserPublication
from zope.publisher.http import HTTPRequest
from zope.publisher.browser import BrowserRequest
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/requestpublicationregistry.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -13,7 +13,6 @@
##############################################################################
"""A registry for Request-Publication factories.
-
$Id: publicationfactories.py 38841 2005-10-07 04:34:09Z andreasjung $
"""
__docformat__ = 'restructuredtext'
@@ -35,14 +34,13 @@
The 'priority' is used to define a lookup-order when multiple
factories are registered for a given method and mime-type.
"""
-
implements(IRequestPublicationRegistry)
def __init__(self):
self._d = {} # method -> { mimetype -> {factories_data}}
def register(self, method, mimetype, name, priority, factory):
- """ registers a factory for method+mimetype """
+ """registers a factory for method+mimetype """
# initialize the two-level deep nested datastructure if necessary
if not self._d.has_key(method):
@@ -51,37 +49,38 @@
self._d[method][mimetype] = []
l = self._d[method][mimetype]
- # Check if there is already a registered publisher factory (check by name).
- # If yes then it will be removed and replaced by a new publisher.
- for pos, d in enumerate(l):
+ # Check if there is already a registered publisher factory (check by
+ # name). If yes then it will be removed and replaced by a new
+ # publisher.
+ for pos, d in enumerate(l):
if d['name'] == name:
del l[pos]
break
- # add the publisher factory + additional informations
+ # add the publisher factory + additional informations
l.append({'name' : name, 'factory' : factory, 'priority' : priority})
# order by descending priority
- l.sort(lambda x,y: -cmp(x['priority'], y['priority']))
+ l.sort(lambda x,y: -cmp(x['priority'], y['priority']))
# check if the priorities are unique
priorities = [item['priority'] for item in l]
if len(sets.Set(priorities)) != len(l):
- raise ConfigurationError('All registered publishers for a given '
+ raise ConfigurationError('All registered publishers for a given '
'method+mimetype must have distinct '
'priorities. Please check your ZCML '
'configuration')
-
+
def getFactoriesFor(self, method, mimetype):
try:
return self._d[method][mimetype]
except:
return None
-
+
def lookup(self, method, mimetype, environment):
- """ Lookup a factory for a given method+mimetype and a
- enviroment.
+ """ Lookup a factory for a given method+mimetype and a
+ enviroment.
"""
factory_lst = self.getFactoriesFor(method, mimetype)
@@ -101,6 +100,12 @@
if factory.canHandle(environment):
return factory
- # Actually we should never get here unless of improper
+ # Actually we should never get here unless of improper
# configuration (no default handler for method=* and mimetype=*
return None
+
+
+factoryRegistry = RequestPublicationRegistry()
+
+from zope.testing import cleanup
+cleanup.addCleanUp(lambda : factoryRegistry.__init__())
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_browserpublication.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_browserpublication.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -291,17 +291,18 @@
def setUp(self):
super(BasePublicationTests, self).setUp()
- from zope.app.publication.metaconfigure import getFactoryRegistry
+ from zope.app.publication.requestpublicationregistry import \
+ factoryRegistry
from zope.app.publication.requestpublicationfactories \
import SOAPFactory, XMLRPCFactory, HTTPFactory, BrowserFactory
- registerer = getFactoryRegistry()
- registerer.register('*', '*', 'HTTP', 0, HTTPFactory())
- registerer.register('POST', 'text/xml', 'SOAP', 20, SOAPFactory())
- registerer.register('POST', 'text/xml', 'XMLRPC', 10, XMLRPCFactory())
- registerer.register('GET', '*', 'BROWSER', 10, BrowserFactory())
- registerer.register('POST', '*', 'BROWSER', 10, BrowserFactory())
- registerer.register('HEAD', '*', 'BROWSER', 10, BrowserFactory())
+ factoryRegistry.register('*', '*', 'HTTP', 0, HTTPFactory())
+ factoryRegistry.register('POST', 'text/xml', 'SOAP', 20, SOAPFactory())
+ factoryRegistry.register('POST', 'text/xml', 'XMLRPC', 10,
+ XMLRPCFactory())
+ factoryRegistry.register('GET', '*', 'BROWSER', 10, BrowserFactory())
+ factoryRegistry.register('POST', '*', 'BROWSER', 10, BrowserFactory())
+ factoryRegistry.register('HEAD', '*', 'BROWSER', 10, BrowserFactory())
def testGetBackSamePublication(self):
factory = HTTPPublicationRequestFactory(db=None)
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_httpfactory.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_httpfactory.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_httpfactory.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -31,6 +31,9 @@
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.testing import ztapi
from zope.app.publication import interfaces
+from zope.app.publication.requestpublicationregistry import factoryRegistry
+from zope.app.publication.requestpublicationfactories import \
+ HTTPFactory, SOAPFactory, BrowserFactory, XMLRPCFactory
class DummyRequestFactory(object):
def __call__(self, input_stream, env):
@@ -53,6 +56,16 @@
'GATEWAY_INTERFACE': 'TestFooInterface/1.0',
}
+ # Simulate standard configuration
+ factoryRegistry.register('GET', '*', 'browser', 0, BrowserFactory())
+ factoryRegistry.register('POST', '*', 'browser', 0, BrowserFactory())
+ factoryRegistry.register('HEAD', '*', 'browser', 0, BrowserFactory())
+ factoryRegistry.register('*', '*', 'http', 0, HTTPFactory())
+ factoryRegistry.register('POST', 'text/xml', 'xmlrpc', 20,
+ XMLRPCFactory())
+ factoryRegistry.register('POST', 'text/xml', 'soap', 30,
+ SOAPFactory())
+
def test_override(self):
# TODO: making a SOAP request without configuring a SOAP request
# currently generates an XMLRPC request. Not sure what the right thing
@@ -100,7 +113,6 @@
self.assertEqual(r.publication.__class__, BrowserPublication)
def test_http(self):
-
for method in ('PUT', 'put', 'ZZZ'):
self.__env['REQUEST_METHOD'] = method
r = self.__factory(StringIO(''), self.__env)
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationfactories.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationfactories.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationfactories.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -31,7 +31,8 @@
from zope.app.publication.xmlrpc import XMLRPCPublication
from zope.app.testing import ztapi
from zope.app.publication import interfaces
-from zope.app.publication.requestpublicationfactories import SOAPFactory, XMLRPCFactory, HTTPFactory, BrowserFactory
+from zope.app.publication.requestpublicationfactories import \
+ SOAPFactory, XMLRPCFactory, HTTPFactory, BrowserFactory
from zope.app.publication.soap import SOAPPublication
from zope.app.publication.browser import BrowserPublication
@@ -43,8 +44,8 @@
def setPublication(self, pub):
self.pub = pub
-
+
class Test(PlacelessSetup, TestCase):
def setUp(self):
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/publication/tests/test_requestpublicationregistry.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -26,8 +26,10 @@
from zope.configuration.exceptions import ConfigurationError
from zope.app.publication import interfaces
from zope.app.publication.interfaces import IRequestPublicationRegistry
-from zope.app.publication.requestpublicationregistry import RequestPublicationRegistry
-from zope.app.publication.requestpublicationfactories import HTTPFactory, SOAPFactory, BrowserFactory, XMLRPCFactory
+from zope.app.publication.requestpublicationregistry import \
+ RequestPublicationRegistry
+from zope.app.publication.requestpublicationfactories import \
+ HTTPFactory, SOAPFactory, BrowserFactory, XMLRPCFactory
def DummyFactory():
@@ -41,7 +43,7 @@
def setPublication(self, pub):
self.pub = pub
-
+
class Test(PlacelessSetup, TestCase):
def test_interface(self):
@@ -56,10 +58,10 @@
browser_f = DummyFactory()
r.register('*', '*', 'browser_default', 0, browser_f)
l = r.getFactoriesFor('POST', 'text/xml')
- self.assertEqual(l, [
- {'name' : 'soap', 'priority' : 1, 'factory' : object},
- {'name' : 'xmlrpc', 'priority' : 0, 'factory' : object},
- ])
+ self.assertEqual(
+ l,
+ [{'name' : 'soap', 'priority' : 1, 'factory' : object},
+ {'name' : 'xmlrpc', 'priority' : 0, 'factory' : object}])
self.assertEqual(r.getFactoriesFor('POST', 'text/html'), None)
def test_configuration_same_priority(self):
@@ -68,7 +70,8 @@
r.register('POST', 'text/xml', 'xmlrpc', 0, DummyFactory)
r.register('POST', 'text/xml', 'soap', 1, DummyFactory())
# try to register a factory with the same priority
- self.assertRaises(ConfigurationError, r.register, 'POST', 'text/xml', 'soap2', 1, DummyFactory())
+ self.assertRaises(ConfigurationError, r.register,
+ 'POST', 'text/xml', 'soap2', 1, DummyFactory())
def test_configuration_reregistration(self):
r = RequestPublicationRegistry()
@@ -108,11 +111,15 @@
soaprequestfactory, interfaces.ISOAPRequestFactory)
component.provideUtility(soaprequestfactory)
- self.assertEqual(isinstance(r.lookup('POST', 'text/xml', env), XMLRPCFactory), True)
+ self.assert_(
+ isinstance(r.lookup('POST', 'text/xml', env), XMLRPCFactory))
env['HTTP_SOAPACTION'] = 'foo'
- self.assertEqual(isinstance(r.lookup('POST', 'text/xml', env), SOAPFactory), True)
- self.assertEqual(isinstance(r.lookup('FOO', 'zope/sucks', env), BrowserFactory), True)
+ self.assert_(
+ isinstance(r.lookup('POST', 'text/xml', env), SOAPFactory))
+ self.assert_(
+ isinstance(r.lookup('FOO', 'zope/sucks', env), BrowserFactory))
+
def test_suite():
return TestSuite((
makeSuite(Test),
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/testing/tests.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/testing/tests.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/testing/tests.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -22,6 +22,8 @@
from zope.testing.doctestunit import DocTestSuite
import zope.app.testing
+from zope.app.publication.requestpublicationregistry import factoryRegistry
+from zope.app.publication.requestpublicationfactories import BrowserFactory
from zope.app.testing import functional
from zope.app.testing.dochttp import dochttp
@@ -170,6 +172,8 @@
def test_chooseRequestClass(self):
from zope.publisher.interfaces import IRequest, IPublication
+ factoryRegistry.register('GET', '*', 'browser', 0, BrowserFactory())
+
caller = functional.HTTPCaller()
request_class, publication_class = caller.chooseRequestClass(
method='GET', path='/', environment={})
Modified: Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/wsgi/tests.py
===================================================================
--- Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/wsgi/tests.py 2005-10-11 21:00:22 UTC (rev 39081)
+++ Zope3/branches/ajung-target-requestpublication-next-try-branch/src/zope/app/wsgi/tests.py 2005-10-11 22:46:43 UTC (rev 39082)
@@ -18,11 +18,17 @@
import unittest
from zope.testing import doctest
from zope.app.testing import placelesssetup
+from zope.app.publication.requestpublicationregistry import factoryRegistry
+from zope.app.publication.requestpublicationfactories import BrowserFactory
+def setUp(test):
+ placelesssetup.setUp(test)
+ factoryRegistry.register('GET', '*', 'browser', 0, BrowserFactory())
+
def test_suite():
return unittest.TestSuite((
doctest.DocFileSuite('README.txt',
- setUp=placelesssetup.setUp,
+ setUp=setUp,
tearDown=placelesssetup.tearDown,
optionflags=doctest.NORMALIZE_WHITESPACE),
))
More information about the Zope3-Checkins
mailing list