[Zope-Checkins] SVN: Zope/trunk/ emoved persistent default content, including the `standard_error_message` template.

Hanno Schlichting hannosch at hannosch.eu
Sat Jul 2 17:49:54 EDT 2011


Log message for revision 122069:
  emoved persistent default content, including the `standard_error_message` template.
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/doc/DEBUGGING.rst
  U   Zope/trunk/src/App/ApplicationManager.py
  D   Zope/trunk/src/App/Product.py
  U   Zope/trunk/src/App/ProductContext.py
  U   Zope/trunk/src/OFS/Application.py
  D   Zope/trunk/src/OFS/standard/
  U   Zope/trunk/src/OFS/tests/testAppInitializer.py
  U   Zope/trunk/src/OFS/tests/testProductInit.py
  U   Zope/trunk/src/Products/SiteAccess/tests/testSiteRoot.py
  U   Zope/trunk/src/ZPublisher/HTTPResponse.py
  U   Zope/trunk/src/ZPublisher/tests/exception_handling.txt
  U   Zope/trunk/src/Zope2/App/startup.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===================================================================
--- Zope/trunk/doc/CHANGES.rst	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/doc/CHANGES.rst	2011-07-02 21:49:54 UTC (rev 122069)
@@ -33,6 +33,9 @@
 Restructuring
 +++++++++++++
 
+- Removed persistent default content, including the `standard_error_message`
+  template.
+
 - Retired icons from the `Zope Management Interface` and various smaller
   cleanups of ZMI screens.
 

Modified: Zope/trunk/doc/DEBUGGING.rst
===================================================================
--- Zope/trunk/doc/DEBUGGING.rst	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/doc/DEBUGGING.rst	2011-07-02 21:49:54 UTC (rev 122069)
@@ -17,5 +17,5 @@
   $ bin/zopectl debug
   Starting debugger (the name "app" is bound to the top-level Zope object)
   >>> app.keys()
-  ['acl_users', 'Control_Panel', 'temp_folder', 'browser_id_manager', 'session_data_manager', 'error_log', 'index_html', 'standard_error_message']
+  ['acl_users']
   >>>

Modified: Zope/trunk/src/App/ApplicationManager.py
===================================================================
--- Zope/trunk/src/App/ApplicationManager.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/App/ApplicationManager.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -17,6 +17,7 @@
 from logging import getLogger
 import os
 import sys
+from thread import get_ident
 import time
 import urllib
 
@@ -35,20 +36,13 @@
 from OFS.Folder import Folder
 from OFS.SimpleItem import Item
 from OFS.SimpleItem import SimpleItem
-from Product import ProductFolder
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile
 from zExceptions import Redirect
 from ZPublisher import Publish
 
 LOG = getLogger('ApplicationManager')
 
-try:
-    from thread import get_ident
-except ImportError:
-    def get_ident():
-        return 0
 
-
 class DatabaseManager(Item, Implicit):
     """Database management (legacy)
     """
@@ -268,8 +262,6 @@
          'meta_type': Database.meta_type},
         {'id': 'DavLocks',
          'meta_type': DavLocks.meta_type},
-        {'id': 'Products',
-         'meta_type': 'Product Management'},
         {'id': 'DebugInfo',
          'meta_type': DebugInfo.meta_type},
         )
@@ -293,9 +285,6 @@
     manage_editProperties = None
     manage_delProperties = None
 
-    def __init__(self):
-        self.Products = ProductFolder()
-
     def _canCopy(self, op=0):
         return 0
 

Deleted: Zope/trunk/src/App/Product.py
===================================================================
--- Zope/trunk/src/App/Product.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/App/Product.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -1,38 +0,0 @@
-##############################################################################
-#
-# Copyright (c) 2002 Zope Foundation and Contributors.
-#
-# 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.
-#
-##############################################################################
-
-from AccessControl.class_init import InitializeClass
-from AccessControl.owner import UnownableOwner
-from OFS.Folder import Folder
-
-
-class ProductFolder(Folder):
-    "Manage a collection of Products"
-
-    id = 'Products'
-    name = title = 'Product Management'
-    meta_type = 'Product Management'
-
-    all_meta_types=()
-    meta_types=()
-
-    # This prevents subobjects from being owned!
-    _owner = UnownableOwner
-
-    def _product(self, name):
-        return getattr(self, name)
-
-    def _canCopy(self, op=0):
-        return 0
-
-InitializeClass(ProductFolder)

Modified: Zope/trunk/src/App/ProductContext.py
===================================================================
--- Zope/trunk/src/App/ProductContext.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/App/ProductContext.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -172,7 +172,7 @@
               #           currently also required by the _verifyObjectPaste
               #           method of CopyContainers like Folders.
               'action': ('manage_addProduct/%s/%s' % (pid, name)),
-              # 'product': No longer used
+              # 'product': product id
               'product': pid,
               # 'permission': Guards the add action.
               'permission': permission,

Modified: Zope/trunk/src/OFS/Application.py
===================================================================
--- Zope/trunk/src/OFS/Application.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/OFS/Application.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -476,9 +476,13 @@
 
     def install_standards(self):
         app = self.getApp()
-        # this defers to a  function for b/c reasons
-        return install_standards(app)
+        if getattr(app, '_standard_objects_have_been_added', None) is None:
+            return
+        delattr(app, '_standard_objects_have_been_added')
+        transaction.get().note('Removed standard objects flag')
+        transaction.commit()
 
+
 def install_products(app=None):
     folder_permissions = get_folder_permissions()
     meta_types = []
@@ -626,34 +630,6 @@
     package_initialized(module, init_func)
 
 
-def install_standards(app):
-    # Check to see if we've already done this before
-    if getattr(app, '_standard_objects_have_been_added', 0):
-        return
-
-    # Install the replaceable standard objects
-    from App.Common import package_home
-    from App.special_dtml import DTMLFile
-
-    std_dir = os.path.join(package_home(globals()), 'standard')
-    wrote = False
-    for fn in os.listdir(std_dir):
-        base, ext = os.path.splitext(fn)
-        if ext == '.dtml':
-            if hasattr(app, base):
-                continue
-            ob = DTMLFile(base, std_dir)
-            app.manage_addProduct['OFSP'].manage_addDTMLMethod(
-                id=base, file=open(ob.raw))
-        else:
-            continue
-        wrote = True
-    if wrote:
-        app._standard_objects_have_been_added = 1
-        transaction.get().note('Installed standard objects')
-        transaction.commit()
-
-
 def pgetattr(product, name, default=install_products, __init__=0):
     if not __init__ and hasattr(product, name):
         return getattr(product, name)

Modified: Zope/trunk/src/OFS/tests/testAppInitializer.py
===================================================================
--- Zope/trunk/src/OFS/tests/testAppInitializer.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/OFS/tests/testAppInitializer.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -100,9 +100,6 @@
         i.install_cp_and_products()
         self.assertTrue(hasattr(app, 'Control_Panel'))
         self.assertEqual(app.Control_Panel.meta_type, 'Control Panel')
-        self.assertTrue(hasattr(app.Control_Panel, 'Products'))
-        self.assertEqual(app.Control_Panel.Products.meta_type,
-                         'Product Management')
 
     def test_install_tempfolder_and_sdc(self):
         self.configure(good_cfg)
@@ -204,17 +201,7 @@
         i.install_products()
         self.assertTrue('__roles__' in Application.misc_.__dict__)
 
-    def test_install_standards(self):
-        self.configure(good_cfg)
-        i = self.getOne()
-        i.install_products() # required
-        i.install_standards()
-        app = i.getApp()
-        self.assertEqual(app.index_html.meta_type, 'Page Template')
-        self.assertEqual(app.standard_error_message.meta_type, 'DTML Method')
-        self.assertTrue(hasattr(app, '_standard_objects_have_been_added'))
 
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest( unittest.makeSuite( TestInitialization ) )

Modified: Zope/trunk/src/OFS/tests/testProductInit.py
===================================================================
--- Zope/trunk/src/OFS/tests/testProductInit.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/OFS/tests/testProductInit.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -216,16 +216,7 @@
                        'container_filter': None}
                       in Products.meta_types)
 
-    def test_install_products(self):
-        self.makeFakeProducts()
-        self.configure(cfg)
-        app = getApp()
-        from OFS.Application import install_products
-        install_products()
-        obids = app.Control_Panel.Products.keys()
-        self.assertEquals(obids, [])
 
-
 def test_suite():
     suite = unittest.TestSuite()
     suite.addTest( unittest.makeSuite( TestProductInit ) )

Modified: Zope/trunk/src/Products/SiteAccess/tests/testSiteRoot.py
===================================================================
--- Zope/trunk/src/Products/SiteAccess/tests/testSiteRoot.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/Products/SiteAccess/tests/testSiteRoot.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -279,13 +279,12 @@
         import transaction
         from Testing.makerequest import makerequest
         from Testing.ZopeTestCase.ZopeLite import app
+        from Products.SiteAccess.SiteRoot import manage_addSiteRoot
         transaction.begin()
         self.app = makerequest(app())
         self.app.manage_addFolder('folder')
-        p_disp = self.app.folder.manage_addProduct['SiteAccess']
-        p_disp.manage_addSiteRoot(title='SiteRoot',
-                                    base='http://test_base',
-                                    path='/test_path')
+        manage_addSiteRoot(self.app.folder, title='SiteRoot',
+            base='http://test_base', path='/test_path')
         self.app.REQUEST.set('PARENTS', [self.app])
         self.app.REQUEST.traverse('/folder')
 
@@ -293,14 +292,13 @@
         import transaction
         transaction.abort()
         self.app._p_jar.close()
-        
+
     def testRequest(self):
-        self.assertEqual(self.app.REQUEST['SERVER_URL'], 'http://test_base') 
-        self.assertEqual(self.app.REQUEST['URL'],
-                         'http://test_base/test_path/index_html')
+        self.assertEqual(self.app.REQUEST['SERVER_URL'], 'http://test_base')
         self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
                          'http://test_base/test_path')
-    def testAbsoluteUrl(self):            
+
+    def testAbsoluteUrl(self):
         self.assertEqual(self.app.folder.absolute_url(),
                          'http://test_base/test_path')
 

Modified: Zope/trunk/src/ZPublisher/HTTPResponse.py
===================================================================
--- Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/ZPublisher/HTTPResponse.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -490,7 +490,6 @@
             else:
                 self.body = body
 
-
         content_type = self.headers.get('content-type')
 
         # Some browsers interpret certain characters in Latin 1 as html
@@ -679,15 +678,16 @@
                 "<body>\n%s\n</body>\n"
                 "</html>\n" % (title,body))
 
-    def _error_html(self,title,body):
-        # XXX could this try to use standard_error_message somehow?
-        return ("""\
+    def _error_html(self, title, body):
+        return ("""<html>
+  <head><title>Site Error</title></head>
+  <body bgcolor="#FFFFFF">
   <h2>Site Error</h2>
   <p>An error was encountered while publishing this resource.
   </p>
   <p><strong>%s</strong></p>
 
-  %s""" %(title,body) + \
+  %s""" % (title, body) + \
   """
   <hr noshade="noshade"/>
 
@@ -700,46 +700,41 @@
       encountering an error.</li>
   </ul>
 
-  <p>For more detailed information about the error, please
-  refer to the error log.
-  </p>
-
   <p>If the error persists please contact the site maintainer.
   Thank you for your patience.
-  </p>""")
+  </p></body></html>""")
 
-
     def notFoundError(self,entry='Unknown'):
         self.setStatus(404)
-        raise NotFound, self._error_html(
+        raise NotFound(self._error_html(
             "Resource not found",
             "Sorry, the requested resource does not exist." +
             "<p>Check the URL and try again.</p>" +
-            "<p><b>Resource:</b> %s</p>" % escape(entry))
+            "<p><b>Resource:</b> %s</p>" % escape(entry)))
 
     forbiddenError = notFoundError  # If a resource is forbidden,
                                     # why reveal that it exists?
 
     def debugError(self,entry):
-        raise NotFound, self._error_html(
+        raise NotFound(self._error_html(
             "Debugging Notice",
             "Zope has encountered a problem publishing your object.<p>"
-            "\n%s</p>" % entry)
+            "\n%s</p>" % entry))
 
     def badRequestError(self,name):
         self.setStatus(400)
         if re.match('^[A-Z_0-9]+$',name):
-            raise InternalError, self._error_html(
+            raise InternalError(self._error_html(
                 "Internal Error",
-                "Sorry, an internal error occurred in this resource.")
+                "Sorry, an internal error occurred in this resource."))
 
-        raise BadRequest, self._error_html(
+        raise BadRequest(self._error_html(
             "Invalid request",
             "The parameter, <em>%s</em>, " % name +
             "was omitted from the request.<p>" +
             "Make sure to specify all required parameters, " +
             "and try the request again.</p>"
-            )
+            ))
 
     def _unauthorized(self):
         realm = self.realm
@@ -753,7 +748,7 @@
                 m = m + '<p>\nUsername and password are not correct.</p>'
             else:
                 m = m + '<p>\nNo Authorization header found.</p>'
-        raise Unauthorized, m
+        raise Unauthorized(m)
 
     def _setBCIHeaders(self, t, tb):
         try:

Modified: Zope/trunk/src/ZPublisher/tests/exception_handling.txt
===================================================================
--- Zope/trunk/src/ZPublisher/tests/exception_handling.txt	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/ZPublisher/tests/exception_handling.txt	2011-07-02 21:49:54 UTC (rev 122069)
@@ -27,10 +27,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 500: Internal Server Error
-    >>> 'Error Type: AttributeError' in browser.contents
-    True
-    >>> 'Error Value: ERROR VALUE' in browser.contents
-    True
 
     >>> browser.handleErrors = False
     >>> browser.open('http://localhost/test_folder_1_/foo')
@@ -48,10 +44,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 500: Internal Server Error
-    >>> 'Error Type: ImportError' in browser.contents
-    True
-    >>> 'Error Value: ERROR VALUE' in browser.contents
-    True
 
     >>> browser.handleErrors = False
     >>> browser.open('http://localhost/test_folder_1_/foo')
@@ -70,10 +62,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 404: Not Found
-    >>> 'Error Type: NotFound' in browser.contents
-    True
-    >>> "Error Value: Object: 'OBJECT', name: 'NAME'" in browser.contents
-    True
 
     >>> browser.handleErrors = False
     >>> browser.open('http://localhost/test_folder_1_/foo')
@@ -133,10 +121,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 401: Unauthorized
-    >>> 'Error Type: Unauthorized' in browser.contents
-    True
-    >>> 'Error Value: ERROR VALUE' in browser.contents
-    True
     >>> browser.headers['WWW-Authenticate']
     'basic realm="Zope2"'
 
@@ -156,10 +140,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 401: Unauthorized
-    >>> 'Error Type: Unauthorized' in browser.contents
-    True
-    >>> 'Error Value: ERROR VALUE \xce\xa9' in browser.contents
-    True
     >>> browser.headers['WWW-Authenticate']
     'basic realm="Zope2"'
 
@@ -181,8 +161,6 @@
     Traceback (most recent call last):
     ...
     HTTPError: HTTP Error 401: Unauthorized
-    >>> 'Site Error' in browser.contents
-    True
     >>> 'You are not authorized to access this resource.' in browser.contents
     True
     >>> browser.headers['WWW-Authenticate']
@@ -212,7 +190,8 @@
     >>> browser.open('http://localhost/test_folder_1_/baz')
     Traceback (most recent call last):
     ...
-    NotFound:   <h2>Site Error</h2>
+    NotFound: <html>
+    ...<h2>Site Error</h2>
     ...<p><strong>Resource not found</strong></p>...
     ...<p><b>Resource:</b> index_html</p>...
     >>> browser.contents

Modified: Zope/trunk/src/Zope2/App/startup.py
===================================================================
--- Zope/trunk/src/Zope2/App/startup.py	2011-07-02 20:26:21 UTC (rev 122068)
+++ Zope/trunk/src/Zope2/App/startup.py	2011-07-02 21:49:54 UTC (rev 122069)
@@ -200,12 +200,16 @@
                     # ouch, a user saw this conflict error :-(
                     self.unresolved_conflict_errors += 1
 
-            try:
-                log = aq_acquire(published, '__error_log__', containment=1)
-            except AttributeError:
+            if isinstance(published, list):
+                # special case for zope root
                 error_log_url = ''
             else:
-                error_log_url = log.raising((t, v, traceback))
+                try:
+                    log = aq_acquire(published, '__error_log__', containment=1)
+                except AttributeError:
+                    error_log_url = ''
+                else:
+                    error_log_url = log.raising((t, v, traceback))
 
             if (REQUEST is None or
                 (getattr(REQUEST.get('RESPONSE', None), '_error_format', '')
@@ -257,9 +261,11 @@
                     break
                 client = aq_parent(client)
                 # If we are going in circles without getting the error_message
-                # just raise
+                # let the response handle it
                 if client is None or aq_base(client) is aq_base(published):
-                    raise t, v, traceback
+                    response = REQUEST.RESPONSE
+                    response.exception()
+                    return response
 
             if REQUEST.get('AUTHENTICATED_USER', None) is None:
                 REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody



More information about the Zope-Checkins mailing list