[Zope3-checkins]
SVN: Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/
added BrowserFactory
Andreas Jung
andreas at andreas-jung.com
Thu Oct 6 13:09:33 EDT 2005
Log message for revision 38813:
added BrowserFactory
Changed:
U Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/publicationfactories.py
U Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/tests/test_publicationfactories.py
-=-
Modified: Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/publicationfactories.py
===================================================================
--- Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/publicationfactories.py 2005-10-06 17:03:29 UTC (rev 38812)
+++ Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/publicationfactories.py 2005-10-06 17:09:32 UTC (rev 38813)
@@ -28,7 +28,9 @@
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.publisher.http import HTTPRequest
+from zope.publisher.browser import BrowserRequest
class SOAPFactory(object):
@@ -67,3 +69,15 @@
interfaces.IHTTPRequestFactory, default=HTTPRequest)
return request_class, HTTPPublication
+class BrowserFactory(object):
+
+ implements(IRequestPublicationFactory)
+
+ def canHandle(self, environment):
+ return True
+
+ def getRequestPublication(self):
+ request_class = component.queryUtility(
+ interfaces.IBrowserRequestFactory, default=BrowserRequest)
+ return request_class, BrowserPublication
+
Modified: Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/tests/test_publicationfactories.py
===================================================================
--- Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/tests/test_publicationfactories.py 2005-10-06 17:03:29 UTC (rev 38812)
+++ Zope3/branches/ajung-tarek-request-publication-branch/src/zope/app/publication/tests/test_publicationfactories.py 2005-10-06 17:09:32 UTC (rev 38813)
@@ -31,8 +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.publicationfactories import SOAPFactory, XMLRPCFactory, HTTPFactory
+from zope.app.publication.publicationfactories import SOAPFactory, XMLRPCFactory, HTTPFactory, BrowserFactory
from zope.app.publication.soap import SOAPPublication
+from zope.app.publication.browser import BrowserPublication
class DummyRequestFactory(object):
def __call__(self, input_stream, env):
@@ -93,6 +94,18 @@
self.assertEqual(isinstance(request, DummyRequestFactory), True)
self.assertEqual(publication, HTTPPublication)
+ def test_browserfactory(self):
+ browserrequestfactory = DummyRequestFactory()
+ interface.directlyProvides(
+ browserrequestfactory, interfaces.IBrowserRequestFactory)
+ component.provideUtility(browserrequestfactory)
+ env = self.__env
+ factory = BrowserFactory()
+ self.assertEqual(factory.canHandle(env), True)
+ request, publication = factory.getRequestPublication()
+ self.assertEqual(isinstance(request, DummyRequestFactory), True)
+ self.assertEqual(publication, BrowserPublication)
+
def test_suite():
return TestSuite((
makeSuite(Test),
More information about the Zope3-Checkins
mailing list