Commit 37ea0ae9 authored by Hanno Schlichting's avatar Hanno Schlichting

emoved persistent default content, including the `standard_error_message` template.

parent e7255b60
...@@ -33,6 +33,9 @@ Features Added ...@@ -33,6 +33,9 @@ Features Added
Restructuring Restructuring
+++++++++++++ +++++++++++++
- Removed persistent default content, including the `standard_error_message`
template.
- Retired icons from the `Zope Management Interface` and various smaller - Retired icons from the `Zope Management Interface` and various smaller
cleanups of ZMI screens. cleanups of ZMI screens.
......
...@@ -17,5 +17,5 @@ and use the Python interpreter normally to inspect results:: ...@@ -17,5 +17,5 @@ and use the Python interpreter normally to inspect results::
$ bin/zopectl debug $ bin/zopectl debug
Starting debugger (the name "app" is bound to the top-level Zope object) Starting debugger (the name "app" is bound to the top-level Zope object)
>>> app.keys() >>> app.keys()
['acl_users', 'Control_Panel', 'temp_folder', 'browser_id_manager', 'session_data_manager', 'error_log', 'index_html', 'standard_error_message'] ['acl_users']
>>> >>>
...@@ -17,6 +17,7 @@ from cStringIO import StringIO ...@@ -17,6 +17,7 @@ from cStringIO import StringIO
from logging import getLogger from logging import getLogger
import os import os
import sys import sys
from thread import get_ident
import time import time
import urllib import urllib
...@@ -35,19 +36,12 @@ from Lifetime import shutdown ...@@ -35,19 +36,12 @@ from Lifetime import shutdown
from OFS.Folder import Folder from OFS.Folder import Folder
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
from OFS.SimpleItem import SimpleItem from OFS.SimpleItem import SimpleItem
from Product import ProductFolder
from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplateFile import PageTemplateFile
from zExceptions import Redirect from zExceptions import Redirect
from ZPublisher import Publish from ZPublisher import Publish
LOG = getLogger('ApplicationManager') LOG = getLogger('ApplicationManager')
try:
from thread import get_ident
except ImportError:
def get_ident():
return 0
class DatabaseManager(Item, Implicit): class DatabaseManager(Item, Implicit):
"""Database management (legacy) """Database management (legacy)
...@@ -268,8 +262,6 @@ class ApplicationManager(Folder, CacheManager): ...@@ -268,8 +262,6 @@ class ApplicationManager(Folder, CacheManager):
'meta_type': Database.meta_type}, 'meta_type': Database.meta_type},
{'id': 'DavLocks', {'id': 'DavLocks',
'meta_type': DavLocks.meta_type}, 'meta_type': DavLocks.meta_type},
{'id': 'Products',
'meta_type': 'Product Management'},
{'id': 'DebugInfo', {'id': 'DebugInfo',
'meta_type': DebugInfo.meta_type}, 'meta_type': DebugInfo.meta_type},
) )
...@@ -293,9 +285,6 @@ class ApplicationManager(Folder, CacheManager): ...@@ -293,9 +285,6 @@ class ApplicationManager(Folder, CacheManager):
manage_editProperties = None manage_editProperties = None
manage_delProperties = None manage_delProperties = None
def __init__(self):
self.Products = ProductFolder()
def _canCopy(self, op=0): def _canCopy(self, op=0):
return 0 return 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)
...@@ -172,7 +172,7 @@ class ProductContext: ...@@ -172,7 +172,7 @@ class ProductContext:
# currently also required by the _verifyObjectPaste # currently also required by the _verifyObjectPaste
# method of CopyContainers like Folders. # method of CopyContainers like Folders.
'action': ('manage_addProduct/%s/%s' % (pid, name)), 'action': ('manage_addProduct/%s/%s' % (pid, name)),
# 'product': No longer used # 'product': product id
'product': pid, 'product': pid,
# 'permission': Guards the add action. # 'permission': Guards the add action.
'permission': permission, 'permission': permission,
......
...@@ -476,8 +476,12 @@ class AppInitializer: ...@@ -476,8 +476,12 @@ class AppInitializer:
def install_standards(self): def install_standards(self):
app = self.getApp() app = self.getApp()
# this defers to a function for b/c reasons if getattr(app, '_standard_objects_have_been_added', None) is None:
return install_standards(app) return
delattr(app, '_standard_objects_have_been_added')
transaction.get().note('Removed standard objects flag')
transaction.commit()
def install_products(app=None): def install_products(app=None):
folder_permissions = get_folder_permissions() folder_permissions = get_folder_permissions()
...@@ -626,34 +630,6 @@ def install_package(app, module, init_func, raise_exc=None): ...@@ -626,34 +630,6 @@ def install_package(app, module, init_func, raise_exc=None):
package_initialized(module, init_func) 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): def pgetattr(product, name, default=install_products, __init__=0):
if not __init__ and hasattr(product, name): if not __init__ and hasattr(product, name):
return getattr(product, name) return getattr(product, name)
......
<html>
<head><title>Site Error</title></head>
<body bgcolor="#FFFFFF">
<dtml-if error_message>
<dtml-var error_message>
<dtml-else>
<h2>Site Error</h2>
<p>An error was encountered while publishing this resource.
</p>
<p>
<strong>Error Type: &dtml-error_type;</strong><br/>
<strong>Error Value: &dtml-error_value;</strong><br/>
</p>
<hr noshade="noshade" />
<p>Troubleshooting Suggestions</p>
<ul>
<dtml-if "error_type in ('KeyError','NameError')">
<li>This resource may be trying to reference a
nonexistent object or variable <strong>&dtml-error_value;</strong>.</li>
</dtml-if>
<li>The URL may be incorrect.</li>
<li>The parameters passed to this resource may be incorrect.</li>
<li>A resource that this resource relies on may be encountering
an error.</li>
</ul>
<p>If the error persists please contact the site maintainer.
Thank you for your patience.
</p>
</dtml-if>
</body>
</html>
...@@ -100,9 +100,6 @@ class TestInitialization( unittest.TestCase ): ...@@ -100,9 +100,6 @@ class TestInitialization( unittest.TestCase ):
i.install_cp_and_products() i.install_cp_and_products()
self.assertTrue(hasattr(app, 'Control_Panel')) self.assertTrue(hasattr(app, 'Control_Panel'))
self.assertEqual(app.Control_Panel.meta_type, '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): def test_install_tempfolder_and_sdc(self):
self.configure(good_cfg) self.configure(good_cfg)
...@@ -204,16 +201,6 @@ class TestInitialization( unittest.TestCase ): ...@@ -204,16 +201,6 @@ class TestInitialization( unittest.TestCase ):
i.install_products() i.install_products()
self.assertTrue('__roles__' in Application.misc_.__dict__) 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(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -216,15 +216,6 @@ class TestProductInit( unittest.TestCase ): ...@@ -216,15 +216,6 @@ class TestProductInit( unittest.TestCase ):
'container_filter': None} 'container_filter': None}
in Products.meta_types) 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(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
......
...@@ -279,13 +279,12 @@ class SiteRootRegressions(unittest.TestCase): ...@@ -279,13 +279,12 @@ class SiteRootRegressions(unittest.TestCase):
import transaction import transaction
from Testing.makerequest import makerequest from Testing.makerequest import makerequest
from Testing.ZopeTestCase.ZopeLite import app from Testing.ZopeTestCase.ZopeLite import app
from Products.SiteAccess.SiteRoot import manage_addSiteRoot
transaction.begin() transaction.begin()
self.app = makerequest(app()) self.app = makerequest(app())
self.app.manage_addFolder('folder') self.app.manage_addFolder('folder')
p_disp = self.app.folder.manage_addProduct['SiteAccess'] manage_addSiteRoot(self.app.folder, title='SiteRoot',
p_disp.manage_addSiteRoot(title='SiteRoot', base='http://test_base', path='/test_path')
base='http://test_base',
path='/test_path')
self.app.REQUEST.set('PARENTS', [self.app]) self.app.REQUEST.set('PARENTS', [self.app])
self.app.REQUEST.traverse('/folder') self.app.REQUEST.traverse('/folder')
...@@ -293,14 +292,13 @@ class SiteRootRegressions(unittest.TestCase): ...@@ -293,14 +292,13 @@ class SiteRootRegressions(unittest.TestCase):
import transaction import transaction
transaction.abort() transaction.abort()
self.app._p_jar.close() self.app._p_jar.close()
def testRequest(self): def testRequest(self):
self.assertEqual(self.app.REQUEST['SERVER_URL'], 'http://test_base') 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['ACTUAL_URL'], self.assertEqual(self.app.REQUEST['ACTUAL_URL'],
'http://test_base/test_path') 'http://test_base/test_path')
def testAbsoluteUrl(self):
def testAbsoluteUrl(self):
self.assertEqual(self.app.folder.absolute_url(), self.assertEqual(self.app.folder.absolute_url(),
'http://test_base/test_path') 'http://test_base/test_path')
......
...@@ -490,7 +490,6 @@ class HTTPResponse(BaseResponse): ...@@ -490,7 +490,6 @@ class HTTPResponse(BaseResponse):
else: else:
self.body = body self.body = body
content_type = self.headers.get('content-type') content_type = self.headers.get('content-type')
# Some browsers interpret certain characters in Latin 1 as html # Some browsers interpret certain characters in Latin 1 as html
...@@ -679,15 +678,16 @@ class HTTPResponse(BaseResponse): ...@@ -679,15 +678,16 @@ class HTTPResponse(BaseResponse):
"<body>\n%s\n</body>\n" "<body>\n%s\n</body>\n"
"</html>\n" % (title,body)) "</html>\n" % (title,body))
def _error_html(self,title,body): def _error_html(self, title, body):
# XXX could this try to use standard_error_message somehow? return ("""<html>
return ("""\ <head><title>Site Error</title></head>
<body bgcolor="#FFFFFF">
<h2>Site Error</h2> <h2>Site Error</h2>
<p>An error was encountered while publishing this resource. <p>An error was encountered while publishing this resource.
</p> </p>
<p><strong>%s</strong></p> <p><strong>%s</strong></p>
%s""" %(title,body) + \ %s""" % (title, body) + \
""" """
<hr noshade="noshade"/> <hr noshade="noshade"/>
...@@ -700,46 +700,41 @@ class HTTPResponse(BaseResponse): ...@@ -700,46 +700,41 @@ class HTTPResponse(BaseResponse):
encountering an error.</li> encountering an error.</li>
</ul> </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. <p>If the error persists please contact the site maintainer.
Thank you for your patience. Thank you for your patience.
</p>""") </p></body></html>""")
def notFoundError(self,entry='Unknown'): def notFoundError(self,entry='Unknown'):
self.setStatus(404) self.setStatus(404)
raise NotFound, self._error_html( raise NotFound(self._error_html(
"Resource not found", "Resource not found",
"Sorry, the requested resource does not exist." + "Sorry, the requested resource does not exist." +
"<p>Check the URL and try again.</p>" + "<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, forbiddenError = notFoundError # If a resource is forbidden,
# why reveal that it exists? # why reveal that it exists?
def debugError(self,entry): def debugError(self,entry):
raise NotFound, self._error_html( raise NotFound(self._error_html(
"Debugging Notice", "Debugging Notice",
"Zope has encountered a problem publishing your object.<p>" "Zope has encountered a problem publishing your object.<p>"
"\n%s</p>" % entry) "\n%s</p>" % entry))
def badRequestError(self,name): def badRequestError(self,name):
self.setStatus(400) self.setStatus(400)
if re.match('^[A-Z_0-9]+$',name): if re.match('^[A-Z_0-9]+$',name):
raise InternalError, self._error_html( raise InternalError(self._error_html(
"Internal Error", "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", "Invalid request",
"The parameter, <em>%s</em>, " % name + "The parameter, <em>%s</em>, " % name +
"was omitted from the request.<p>" + "was omitted from the request.<p>" +
"Make sure to specify all required parameters, " + "Make sure to specify all required parameters, " +
"and try the request again.</p>" "and try the request again.</p>"
) ))
def _unauthorized(self): def _unauthorized(self):
realm = self.realm realm = self.realm
...@@ -753,7 +748,7 @@ class HTTPResponse(BaseResponse): ...@@ -753,7 +748,7 @@ class HTTPResponse(BaseResponse):
m = m + '<p>\nUsername and password are not correct.</p>' m = m + '<p>\nUsername and password are not correct.</p>'
else: else:
m = m + '<p>\nNo Authorization header found.</p>' m = m + '<p>\nNo Authorization header found.</p>'
raise Unauthorized, m raise Unauthorized(m)
def _setBCIHeaders(self, t, tb): def _setBCIHeaders(self, t, tb):
try: try:
......
...@@ -27,10 +27,6 @@ Handle AttributeError. ...@@ -27,10 +27,6 @@ Handle AttributeError.
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 500: Internal Server Error 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.handleErrors = False
>>> browser.open('http://localhost/test_folder_1_/foo') >>> browser.open('http://localhost/test_folder_1_/foo')
...@@ -48,10 +44,6 @@ Handle ImportError. ...@@ -48,10 +44,6 @@ Handle ImportError.
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 500: Internal Server Error 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.handleErrors = False
>>> browser.open('http://localhost/test_folder_1_/foo') >>> browser.open('http://localhost/test_folder_1_/foo')
...@@ -70,10 +62,6 @@ Handle zope.publisher.interfaces.NotFound. ...@@ -70,10 +62,6 @@ Handle zope.publisher.interfaces.NotFound.
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 404: Not Found 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.handleErrors = False
>>> browser.open('http://localhost/test_folder_1_/foo') >>> browser.open('http://localhost/test_folder_1_/foo')
...@@ -133,10 +121,6 @@ Handle zExceptions.Unauthorized raised by the object. We take the ...@@ -133,10 +121,6 @@ Handle zExceptions.Unauthorized raised by the object. We take the
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 401: Unauthorized HTTPError: HTTP Error 401: Unauthorized
>>> 'Error Type: Unauthorized' in browser.contents
True
>>> 'Error Value: ERROR VALUE' in browser.contents
True
>>> browser.headers['WWW-Authenticate'] >>> browser.headers['WWW-Authenticate']
'basic realm="Zope2"' 'basic realm="Zope2"'
...@@ -156,10 +140,6 @@ And the same with unicode error value. ...@@ -156,10 +140,6 @@ And the same with unicode error value.
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 401: Unauthorized 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'] >>> browser.headers['WWW-Authenticate']
'basic realm="Zope2"' 'basic realm="Zope2"'
...@@ -181,8 +161,6 @@ Handle zExceptions.Unauthorized raised by BaseRequest.traverse. We take the ...@@ -181,8 +161,6 @@ Handle zExceptions.Unauthorized raised by BaseRequest.traverse. We take the
Traceback (most recent call last): Traceback (most recent call last):
... ...
HTTPError: HTTP Error 401: Unauthorized HTTPError: HTTP Error 401: Unauthorized
>>> 'Site Error' in browser.contents
True
>>> 'You are not authorized to access this resource.' in browser.contents >>> 'You are not authorized to access this resource.' in browser.contents
True True
>>> browser.headers['WWW-Authenticate'] >>> browser.headers['WWW-Authenticate']
...@@ -212,7 +190,8 @@ converts it into zExceptions.NotFound if we are not in debug mode. ...@@ -212,7 +190,8 @@ converts it into zExceptions.NotFound if we are not in debug mode.
>>> browser.open('http://localhost/test_folder_1_/baz') >>> browser.open('http://localhost/test_folder_1_/baz')
Traceback (most recent call last): Traceback (most recent call last):
... ...
NotFound: <h2>Site Error</h2> NotFound: <html>
...<h2>Site Error</h2>
...<p><strong>Resource not found</strong></p>... ...<p><strong>Resource not found</strong></p>...
...<p><b>Resource:</b> index_html</p>... ...<p><b>Resource:</b> index_html</p>...
>>> browser.contents >>> browser.contents
...@@ -200,12 +200,16 @@ class ZPublisherExceptionHook: ...@@ -200,12 +200,16 @@ class ZPublisherExceptionHook:
# ouch, a user saw this conflict error :-( # ouch, a user saw this conflict error :-(
self.unresolved_conflict_errors += 1 self.unresolved_conflict_errors += 1
try: if isinstance(published, list):
log = aq_acquire(published, '__error_log__', containment=1) # special case for zope root
except AttributeError:
error_log_url = '' error_log_url = ''
else: 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 if (REQUEST is None or
(getattr(REQUEST.get('RESPONSE', None), '_error_format', '') (getattr(REQUEST.get('RESPONSE', None), '_error_format', '')
...@@ -257,9 +261,11 @@ class ZPublisherExceptionHook: ...@@ -257,9 +261,11 @@ class ZPublisherExceptionHook:
break break
client = aq_parent(client) client = aq_parent(client)
# If we are going in circles without getting the error_message # 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): 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: if REQUEST.get('AUTHENTICATED_USER', None) is None:
REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody REQUEST['AUTHENTICATED_USER'] = AccessControl.User.nobody
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment