[Zope-Checkins] SVN: Zope/branches/publication-refactor2/lib/python/ Finish committing changes from the publication-refactor branch.

Michael Kerrin michael.kerrin at openapp.biz
Fri Apr 21 13:37:22 EDT 2006


Log message for revision 67238:
  Finish committing changes from the publication-refactor branch.
  
  Also fixed bug in the traversal when we were always getting
  unauthorized errors when trying to use Five views. This was
  because I had left out some code from the Five.traversable.
  

Changed:
  _U  Zope/branches/publication-refactor2/lib/python/
  U   Zope/branches/publication-refactor2/lib/python/ZPublisher/BaseRequest.py
  U   Zope/branches/publication-refactor2/lib/python/ZPublisher/Publication.py
  U   Zope/branches/publication-refactor2/lib/python/ZPublisher/Test.py
  U   Zope/branches/publication-refactor2/lib/python/ZServer/HTTPResponse.py
  U   Zope/branches/publication-refactor2/lib/python/Zope2/Startup/__init__.py
  U   Zope/branches/publication-refactor2/lib/python/Zope2/Startup/handlers.py
  U   Zope/branches/publication-refactor2/lib/python/Zope2/Startup/zopeschema.xml
  _U  Zope/branches/publication-refactor2/lib/python/zope/

-=-

Property changes on: Zope/branches/publication-refactor2/lib/python
___________________________________________________________________
Name: svn:externals
   - ZConfig        svn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3.1
BTrees         -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/BTrees
persistent     -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/persistent
ThreadedAsync  -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ThreadedAsync
transaction    -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/transaction
ZEO            -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZEO
ZODB           -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZODB
ZopeUndo       -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZopeUndo
zdaemon        -r 40792 svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon
pytz           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/pytz
zodbcode       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zodbcode
ClientCookie   -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/ClientCookie
mechanize      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/mechanize
docutils       svn://svn.zope.org/repos/main/docutils/tags/0.4.0


   + ZConfig        svn://svn.zope.org/repos/main/ZConfig/tags/ZConfig-2.3.1
BTrees         -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/BTrees
persistent     -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/persistent
ThreadedAsync  -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ThreadedAsync
transaction    -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/transaction
ZEO            -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZEO
ZODB           -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZODB
ZopeUndo       -r 41153 svn://svn.zope.org/repos/main/ZODB/branches/3.6/src/ZopeUndo
zdaemon        -r 40792 svn://svn.zope.org/repos/main/zdaemon/trunk/src/zdaemon
pytz           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/pytz
zodbcode       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zodbcode
ClientCookie   -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/ClientCookie
mechanize      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/mechanize
docutils       svn://svn.zope.org/repos/main/docutils/tags/0.4.0
twisted        svn://svn.twistedmatrix.com/svn/Twisted/branches/releases/2.1.x/twisted


Modified: Zope/branches/publication-refactor2/lib/python/ZPublisher/BaseRequest.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/ZPublisher/BaseRequest.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/ZPublisher/BaseRequest.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -255,6 +255,10 @@
         # Set the posttraverse for duration of the traversal here
         self._post_traverse = post_traverse = []
 
+        # Con Zope 3 into using Zope 2's checkPermission
+        import Products.Five.security
+        Products.Five.security.newInteraction()
+
         entry_name = ''
         try:
             # We build parents in the wrong order, so we

Modified: Zope/branches/publication-refactor2/lib/python/ZPublisher/Publication.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/ZPublisher/Publication.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/ZPublisher/Publication.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -251,7 +251,7 @@
                 except TraversalError:
                     raise NotFound(ob, name)
 
-                return ob2
+                return ob2.__of__(ob)
 
         if nm == '.':
             return ob
@@ -360,12 +360,12 @@
         # 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)
+            doc = getattr(object, '%s__doc__' % name, None)
         if not doc:
             return request.response.debugError(
                 "The object at %s has an empty or missing " \
                 "docstring. Objects must have a docstring to be " \
-                "published." % URL
+                "published." % request['URL']
                 )
 
         # Hack for security: in Python 2.2.2, most built-in types
@@ -376,7 +376,7 @@
 
         if not typeCheck(subobject):
             return request.response.debugError(
-                "The object at %s is not publishable." % URL
+                "The object at %s is not publishable." % request['URL']
                 )
 
         return subobject

Modified: Zope/branches/publication-refactor2/lib/python/ZPublisher/Test.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/ZPublisher/Test.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/ZPublisher/Test.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -198,7 +198,7 @@
         request.setPublication(get_publication())
         for k, v in extra.items(): request[k]=v
         response = request.response
-        publish(request) #, module_name, after_list, debug=debug)
+        publish(request, False) #, module_name, after_list, debug=debug)
     except SystemExit, v:
         must_die=sys.exc_info()
         response.exception(must_die)

Modified: Zope/branches/publication-refactor2/lib/python/ZServer/HTTPResponse.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/ZServer/HTTPResponse.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/ZServer/HTTPResponse.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -251,6 +251,7 @@
             return self
         else:
             HTTPResponse.setBody(self, body, title, is_error, **kw)
+            return self
 
 class ChannelPipe:
     """Experimental pipe from ZPublisher to a ZServer Channel.

Modified: Zope/branches/publication-refactor2/lib/python/Zope2/Startup/__init__.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/Zope2/Startup/__init__.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/Zope2/Startup/__init__.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -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/publication-refactor2/lib/python/Zope2/Startup/handlers.py
===================================================================
--- Zope/branches/publication-refactor2/lib/python/Zope2/Startup/handlers.py	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/Zope2/Startup/handlers.py	2006-04-21 17:37:21 UTC (rev 67238)
@@ -1,8 +1,15 @@
 import os
 import sys
+import time
+import logging
 from re import compile
 from socket import gethostbyaddr
 
+import twisted.internet
+import zope.event
+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,26 @@
                         config.cgi_environment,
                         config.port_base)
 
+    if not config.twisted_servers:
+        config.twisted_servers = []
+    else:
+        db = object() # config.db_tab.getDatabase(mount_point='/')
+        zope.event.notify(zope.app.appsetup.interfaces.DatabaseOpened(db))
+
+        # Set number of threads (reuse zserver_threads variable)
+        twisted.internet.reactor.suggestThreadPoolSize(config.zserver_threads)
+
+        # Create a root service
+        rootService = zope.app.twisted.main.ZopeService()
+
+        for server in config.twisted_servers:
+            service = server.create(db)
+            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 +245,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 import wsgi
+from zope.app.twisted.server import ServerType, SSLServerType
+from zope.app.twisted.interfaces import IServerType
+
+def createHTTPFactory(db):
+    resource = twisted.web2.wsgi.WSGIResource(
+        wsgi.WSGIPublisherApplication(db))
+    resource = twisted.web2.log.LogWrapperResource(resource)
+
+    return HTTPFactory(twisted.web2.server.Site(resource))
+
+http = ServerType(createHTTPFactory, 8080)
+
+provideUtility(http, IServerType, 'Zope2-HTTP')

Modified: Zope/branches/publication-refactor2/lib/python/Zope2/Startup/zopeschema.xml
===================================================================
--- Zope/branches/publication-refactor2/lib/python/Zope2/Startup/zopeschema.xml	2006-04-21 17:36:54 UTC (rev 67237)
+++ Zope/branches/publication-refactor2/lib/python/Zope2/Startup/zopeschema.xml	2006-04-21 17:37:21 UTC (rev 67238)
@@ -11,6 +11,12 @@
   <import package="tempstorage"/>
   <import package="Zope2.Startup" file="warnfilter.xml"/>
 
+  <sectiontype name="server" datatype="zope.app.twisted.server.ServerFactory">
+    <key name="type" required="yes" />
+    <key name="address" datatype="inet-address" />
+    <key name="backlog" datatype="integer" default="50" />
+  </sectiontype>
+
   <sectiontype name="logger" datatype=".LoggerFactory">
     <description>
       This "logger" type only applies to access and request ("trace")
@@ -805,7 +811,9 @@
      <metadefault>on</metadefault>
   </key>
 
+  <multisection type="server" name="*" attribute="twisted_servers" />
   <multisection type="ZServer.server" name="*" attribute="servers"/>
+
   <key name="port-base" datatype="integer" default="0">
     <description>
       Base port number that gets added to the specific port numbers


Property changes on: Zope/branches/publication-refactor2/lib/python/zope
___________________________________________________________________
Name: svn:externals
   - app              -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/app
cachedescriptors -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/cachedescriptors
component        -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/component
configuration    -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/configuration
documenttemplate -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/documenttemplate
event            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/event
exceptions       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/exceptions
hookable         -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/hookable
i18n             -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18n
i18nmessageid    -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18nmessageid
interface        -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/interface
modulealias      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/modulealias
pagetemplate     -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/pagetemplate
proxy            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/proxy
publisher        -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/publisher
schema           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/schema
security         -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/security
server           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/server
structuredtext   -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/structuredtext
tal              -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tal
tales            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tales
testing          -r 40941 svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
thread           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/thread
deprecation      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/deprecation
dottedname       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/dottedname
formlib          -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/formlib
index            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/index
testbrowser      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/testbrowser
contentprovider  -r 66018 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/contentprovider
viewlet          -r 66018 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/viewlet


   + app              -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/app
cachedescriptors -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/cachedescriptors
component        -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/component
configuration    -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/configuration
documenttemplate -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/documenttemplate
event            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/event
exceptions       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/exceptions
hookable         -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/hookable
i18n             -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18n
i18nmessageid    -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/i18nmessageid
interface        -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/interface
modulealias      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/modulealias
pagetemplate     -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/pagetemplate
proxy            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/proxy
publisher        svn://svn.zope.org/repos/main/Zope3/branches/publication-refactor2/src/zope/publisher
schema           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/schema
security         -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/security
server           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/server
structuredtext   -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/structuredtext
tal              -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tal
tales            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/tales
testing          -r 40941 svn://svn.zope.org/repos/main/zope.testing/trunk/src/zope/testing
thread           -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/thread
deprecation      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/deprecation
dottedname       -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/dottedname
formlib          -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/formlib
index            -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/index
testbrowser      -r 41215 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/testbrowser
contentprovider  -r 66018 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/contentprovider
viewlet          -r 66018 svn://svn.zope.org/repos/main/Zope3/trunk/src/zope/viewlet






More information about the Zope-Checkins mailing list