[Zope-Checkins] SVN: Zope/trunk/ Integrate Zope 3-based exception views. Patch by Sidnei, integration

2007-07-05 Thread Martijn Faassen
Log message for revision 77459:
  Integrate Zope 3-based exception views. Patch by Sidnei, integration
  work done for Infrae.
  

Changed:
  U   Zope/trunk/doc/CHANGES.txt
  U   Zope/trunk/lib/python/Zope2/App/startup.py
  A   Zope/trunk/lib/python/Zope2/App/tests/
  A   Zope/trunk/lib/python/Zope2/App/tests/__init__.py
  A   Zope/trunk/lib/python/Zope2/App/tests/testExceptionHook.py
  U   Zope/trunk/lib/python/zExceptions/__init__.py
  U   Zope/trunk/lib/python/zExceptions/unauthorized.py

-=-
Modified: Zope/trunk/doc/CHANGES.txt
===
--- Zope/trunk/doc/CHANGES.txt  2007-07-05 13:34:33 UTC (rev 77458)
+++ Zope/trunk/doc/CHANGES.txt  2007-07-05 14:35:49 UTC (rev 77459)
@@ -100,6 +100,27 @@
   - AccessControl: the form behind the Security tab has a new form
 for user-related reporting of permissions and roles
 
+  - Zope 3-based exception views can now be registered in ZCML for
+various exceptions that can be raised by Zope. Registering an
+exception view can be done like this:
+
+  browser:page
+for=zope.publisher.interfaces.INotFound
+class=.view.SomeView
+name=index.html
+permission=zope.Public /
+
+Relevant exceptions that can have views are:
+
+zope.interface.common.interfaces.IException
+zope.publisher.interfaces.INotFound
+zope.security.interfaces.IForbidden
+zope.security.interfaces.IUnauthorized
+
+Note that the name has to be 'index.html' for the exception
+view to work. (patch by Sidnei da Silva from Enfold,
+integration by Martijn Faassen (Startifact) for Infrae)
+
 Bugs Fixed
 
   - Collector #1306: Missing acquisition context on local roles screen.

Modified: Zope/trunk/lib/python/Zope2/App/startup.py
===
--- Zope/trunk/lib/python/Zope2/App/startup.py  2007-07-05 13:34:33 UTC (rev 
77458)
+++ Zope/trunk/lib/python/Zope2/App/startup.py  2007-07-05 14:35:49 UTC (rev 
77459)
@@ -13,6 +13,7 @@
 Initialize the Zope2 Package and provide a published module
 
 
+from zope.component import queryMultiAdapter
 from AccessControl.SecurityManagement import getSecurityManager
 from AccessControl.SecurityManagement import newSecurityManager
 from AccessControl.SecurityManagement import noSecurityManager
@@ -20,7 +21,7 @@
 from App.config import getConfiguration
 from time import asctime
 from types import StringType, ListType
-from zExceptions import Unauthorized
+from zExceptions import Unauthorized, Redirect
 from ZODB.POSException import ConflictError
 import transaction
 import AccessControl.User
@@ -37,6 +38,8 @@
 import Zope2
 import ZPublisher
 
+app = None
+startup_time = asctime()
 
 def startup():
 global app
@@ -132,100 +135,124 @@
 )
 Zope2.DB.removeVersionPool(version)
 raise Unauthorized, You don't have permission to enter versions.
-
 
 
+
 class RequestContainer(ExtensionClass.Base):
 def __init__(self,r): self.REQUEST=r
 
-conflict_errors = 0
-unresolved_conflict_errors = 0
+class ZPublisherExceptionHook:
 
-conflict_logger = logging.getLogger('ZPublisher.Conflict')
+def __init__(self):
+self.conflict_errors = 0
+self.unresolved_conflict_errors = 0
+self.conflict_logger = logging.getLogger('ZPublisher.Conflict')
+self.error_message = 'standard_error_message'
+self.raise_error_message = 'raise_standardErrorMessage'
 
-def zpublisher_exception_hook(published, REQUEST, t, v, traceback):
-global unresolved_conflict_errors
-global conflict_errors
-try:
-if isinstance(t, StringType):
-if t.lower() in ('unauthorized', 'redirect'):
-raise
-else:
-if t is SystemExit:
-raise
-if issubclass(t, ConflictError):
-conflict_errors += 1
-level = getConfiguration().conflict_error_log_level
-if level:
-conflict_logger.log(level,
-%s at %s: %s (%d conflicts (%d unresolved) 
-since startup at %s),
-v.__class__.__name__,
-REQUEST.get('PATH_INFO', 'unknown'),
-v,
-conflict_errors,
-unresolved_conflict_errors,
-startup_time)
-raise ZPublisher.Retry(t, v, traceback)
-if t is ZPublisher.Retry:
-try:
-v.reraise()
-except:
-# we catch the re-raised exception so that it gets
-# stored in the error log and gets rendered with
-# standard_error_message
-t, v, traceback = sys.exc_info()
-if issubclass(t, ConflictError):
-

[Zope-Checkins] SVN: zdaemon/branches/jim-env/ retire old dev branch

2007-07-05 Thread Jim Fulton
Log message for revision 77463:
  retire old dev branch

Changed:
  D   zdaemon/branches/jim-env/

-=-
___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins


[Zope-Checkins] SVN: zdaemon/branches/tseaver-eggification/ retire old dev branch

2007-07-05 Thread Jim Fulton
Log message for revision 77462:
  retire old dev branch

Changed:
  D   zdaemon/branches/tseaver-eggification/

-=-
___
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins