[Zope3-checkins] CVS: Zope3/src/zope/app/startup - configure.zcml:1.4 metaconfigure.py:1.3 requestfactory.py:1.3 requestfactoryregistry.py:1.3 simpleregistry.py:1.3

Jim Fulton jim@zope.com
Fri, 7 Feb 2003 11:00:18 -0500


Update of /cvs-repository/Zope3/src/zope/app/startup
In directory cvs.zope.org:/tmp/cvs-serv24670/src/zope/app/startup

Modified Files:
	configure.zcml metaconfigure.py requestfactory.py 
	requestfactoryregistry.py simpleregistry.py 
Log Message:
Implemented HTTP PUT. Do do this, I had to:

- Implement working HTTP publication, request, response

- Change the server setup so that rather than having a Browser
  server and an XML-RPC server, there is an HTTP server that 
  uses:

  o Browser request, response, and publication for browser (GET, POST, 
    and HEAD) requests,

  o XMLRPC request, response, and publication for xml-rpc (POST 
    w content-type=='text/xml') requests,

  o HTTP request, response, and publication for all other HTTP requests.

  XML-RPC now runs on the same port, 8080, as browser requests.

- Implemented HEAD.

- Implemented some simple PUT views that use the
  file-system-reprentation adapter framework. (This is the replacement
  for VFS that is also used by FTP and may be used as part of
  file-system synchronization.) 
  



=== Zope3/src/zope/app/startup/configure.zcml 1.3 => 1.4 ===
--- Zope3/src/zope/app/startup/configure.zcml:1.3	Mon Feb  3 10:08:49 2003
+++ Zope3/src/zope/app/startup/configure.zcml	Fri Feb  7 10:59:45 2003
@@ -3,6 +3,12 @@
    xmlns:startup="http://namespaces.zope.org/startup">
 
 
+  <startup:registerRequestFactory 
+    name="HTTPRequestFactory"
+    factory="zope.app.publication.httpfactory"
+  />
+
+
   <startup:registerRequestFactory name="BrowserRequestFactory"
     publication = 
     "zope.app.publication.browser.BrowserPublication"
@@ -22,6 +28,14 @@
     request = "zope.publisher.ftp.FTPRequest" 
   />
 
+
+  <startup:registerServerType 
+    name = "HTTP"
+    factory = "zope.server.http.publisherhttpserver.PublisherHTTPServer"
+    requestFactory="HTTPRequestFactory"
+    logFactory = "zope.server.http.commonhitlogger.CommonHitLogger"
+    defaultPort="8080"
+    defaultVerbose="true" />
 
   <startup:registerServerType 
     name = "Browser"


=== Zope3/src/zope/app/startup/metaconfigure.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/startup/metaconfigure.py:1.2	Wed Dec 25 09:13:24 2002
+++ Zope3/src/zope/app/startup/metaconfigure.py	Fri Feb  7 10:59:45 2003
@@ -27,10 +27,20 @@
 defineSite = SiteDefinition
 
 
-def registerRequestFactory(_context, name, publication, request):
-    publication = _context.resolve(publication)
-    request = _context.resolve(request)
-    request_factory = RequestFactory(publication, request)
+def registerRequestFactory(_context, name, request=None, publication=None,
+                           factory=None):
+
+    if factory:
+        if request or publication:
+            raise ValuesError(
+                """Can't provide a request or publication (factory) if you
+                provide a (request) factory""")
+        request_factory = _context.resolve(factory)
+
+    else:
+        publication = _context.resolve(publication)
+        request = _context.resolve(request)
+        request_factory = RequestFactory(publication, request)
 
     return [
         Action(


=== Zope3/src/zope/app/startup/requestfactory.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/startup/requestfactory.py:1.2	Wed Dec 25 09:13:24 2002
+++ Zope3/src/zope/app/startup/requestfactory.py	Fri Feb  7 10:59:45 2003
@@ -14,28 +14,8 @@
 """ctory.py,v 1.1.2.2 2002/04/02 02:20:40 srichter Exp $
 """
 
-from zope.interface import Interface
 import copy
-
-
-class IRequestFactory(Interface):
-    """This is a pure read-only interface, since the values are set through
-       a ZCML directive and we shouldn't be able to change them.
-    """
-
-    def realize(db):
-        """Realize the factory by initalizing the publication.
-
-           The method returns the realized object.
-        """
-
-
-    def __call__(input_stream, output_steam, env):
-        """Call the Request Factory"""
-
-
-
-
+from zope.app.interfaces.startup import IRequestFactory
 
 class RequestFactory:
     """This class will generically create RequestFactories. This way I do


=== Zope3/src/zope/app/startup/requestfactoryregistry.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/startup/requestfactoryregistry.py:1.2	Wed Dec 25 09:13:24 2002
+++ Zope3/src/zope/app/startup/requestfactoryregistry.py	Fri Feb  7 10:59:45 2003
@@ -16,7 +16,7 @@
 """
 from zope.app.interfaces.startup.simpleregistry import ISimpleRegistry
 from zope.app.startup.simpleregistry import SimpleRegistry
-from zope.app.startup.requestfactory import IRequestFactory
+from zope.app.interfaces.startup import IPublicationRequestFactoryFactory
 
 
 class IRequestFactoryRegistry(ISimpleRegistry):
@@ -32,9 +32,16 @@
 
 
 class RequestFactoryRegistry(SimpleRegistry):
-    __implements__ =  (IRequestFactoryRegistry,)
+    __implements__ =  IRequestFactoryRegistry
 
 
-RequestFactoryRegistry = RequestFactoryRegistry(IRequestFactory)
+RequestFactoryRegistry = RequestFactoryRegistry(
+    IPublicationRequestFactoryFactory)
+
 registerRequestFactory = RequestFactoryRegistry.register
 getRequestFactory = RequestFactoryRegistry.get
+
+# Register our cleanup with Testing.CleanUp to make writing unit tests simpler.
+from zope.testing.cleanup import addCleanUp
+addCleanUp(RequestFactoryRegistry._clear)
+del addCleanUp


=== Zope3/src/zope/app/startup/simpleregistry.py 1.2 => 1.3 ===
--- Zope3/src/zope/app/startup/simpleregistry.py:1.2	Wed Dec 25 09:13:24 2002
+++ Zope3/src/zope/app/startup/simpleregistry.py	Fri Feb  7 10:59:45 2003
@@ -64,6 +64,8 @@
         self.objects = {}
         self.interface = interface
 
+    def _clear(self):
+        self.objects.clear()
 
     def register(self, name, object):
         '''See ISimpleRegistry'''
@@ -71,17 +73,8 @@
         if name in self.objects.keys():
             raise ZopeDuplicateRegistryEntryError(name)
 
-        # XXX Find the right Interface tools to do that; unfortunately,
-        #     I have not found them
-        # Check whether the object implements the right interface.
-        # Note, that we do *not* know whether the object is an instance
-        # or a class (or worse a Persistent class)
-        if hasattr(object, '__implements__') and \
-               ( self.interface == object.__implements__ or \
-                 ( type(object.__implements__) in ListTypes and
-                   self.interface in object.__implements__ ) ):
+        if self.interface.isImplementedBy(object):
             self.objects[name] = object
-
         else:
             raise ZopeIllegalInterfaceError(name, self.interface)