[Zope-Checkins] SVN: Zope/branches/haufe-legacy-integration/ - Launchpad #374719: introducing new ZPublisher events:

2009-05-11 Thread Andreas Jung
Log message for revision 99835:
  
  - Launchpad #374719: introducing new ZPublisher events:
PubStart, PubSuccess, PubFailure, PubAfterTraversal and PubBeforeCommit
  

Changed:
  U   Zope/branches/haufe-legacy-integration/doc/CHANGES.rst
  U   Zope/branches/haufe-legacy-integration/src/ZPublisher/Publish.py
  A   Zope/branches/haufe-legacy-integration/src/ZPublisher/interfaces.py
  A   Zope/branches/haufe-legacy-integration/src/ZPublisher/pubevents.py
  A   
Zope/branches/haufe-legacy-integration/src/ZPublisher/tests/testpubevents.py

-=-
Modified: Zope/branches/haufe-legacy-integration/doc/CHANGES.rst
===
--- Zope/branches/haufe-legacy-integration/doc/CHANGES.rst  2009-05-11 
06:55:54 UTC (rev 99834)
+++ Zope/branches/haufe-legacy-integration/doc/CHANGES.rst  2009-05-11 
08:07:25 UTC (rev 99835)
@@ -23,6 +23,9 @@
 Features Added
 ++
 
+- Launchpad #374719: introducing new ZPublisher events:
+  PubStart, PubSuccess, PubFailure, PubAfterTraversal and PubBeforeCommit
+
 - Launchpad #373583: ZODBMountPoint - fixed broken mount support and 
   extended the test suite.
 

Modified: Zope/branches/haufe-legacy-integration/src/ZPublisher/Publish.py
===
--- Zope/branches/haufe-legacy-integration/src/ZPublisher/Publish.py
2009-05-11 06:55:54 UTC (rev 99834)
+++ Zope/branches/haufe-legacy-integration/src/ZPublisher/Publish.py
2009-05-11 08:07:25 UTC (rev 99835)
@@ -24,7 +24,11 @@
 from zope.publisher.interfaces import ISkinnable
 from zope.publisher.skinnable import setDefaultSkin
 from zope.security.management import newInteraction, endInteraction
+from zope.event import notify
 
+from pubevents import PubStart, PubSuccess, PubFailure, \
+ PubBeforeCommit, PubAfterTraversal
+
 class Retry(Exception):
 Raise this to retry a request
 
@@ -76,6 +80,7 @@
 response=None
 
 try:
+notify(PubStart(request))
 # TODO pass request here once BaseRequest implements IParticipation
 newInteraction()
 
@@ -110,6 +115,8 @@
 
 object=request.traverse(path, validated_hook=validated_hook)
 
+notify(PubAfterTraversal(request))
+
 if transactions_manager:
 transactions_manager.recordMetaData(object, request)
 
@@ -122,12 +129,18 @@
 if result is not response:
 response.setBody(result)
 
+notify(PubBeforeCommit(request))
+
 if transactions_manager:
 transactions_manager.commit()
 endInteraction()
 
+notify(PubSuccess(request))
+
 return response
 except:
+# save in order to give 'PubFailure' the original exception info
+exc_info = sys.exc_info()
 # DM: provide nicer error message for FTP
 sm = None
 if response is not None:
@@ -141,6 +154,7 @@
 debug_mode and compact_traceback()[-1] or ''))
 
 if err_hook is not None:
+retry = False
 if parents:
 parents=parents[0]
 try:
@@ -157,10 +171,15 @@
 sys.exc_info()[1],
 sys.exc_info()[2],
 )
+retry = True
 finally:
-if transactions_manager:
-transactions_manager.abort()
-endInteraction()
+# Note: 'abort's can fail. Nevertheless, we want end request 
handling
+try: 
+if transactions_manager:
+transactions_manager.abort()
+finally:
+endInteraction()
+notify(PubFailure(request, exc_info, retry))
 
 # Only reachable if Retry is raised and request supports retry.
 newrequest=request.retry()
@@ -175,9 +194,13 @@
 newrequest.close()
 
 else:
-if transactions_manager:
-transactions_manager.abort()
-endInteraction()
+# Note: 'abort's can fail. Nevertheless, we want end request 
handling
+try:
+if transactions_manager:
+transactions_manager.abort()
+finally:
+endInteraction()
+notify(PubFailure(request, exc_info, False))
 raise
 
 

Added: Zope/branches/haufe-legacy-integration/src/ZPublisher/interfaces.py
===
--- Zope/branches/haufe-legacy-integration/src/ZPublisher/interfaces.py 
(rev 0)
+++ Zope/branches/haufe-legacy-integration/src/ZPublisher/interfaces.py 
2009-05-11 08:07:25 UTC (rev 99835)
@@ -0,0 +1,45 @@
+from zope.interface import Interface, Attribute
+
+#
+# Publication events

[Zope-Checkins] SVN: Zope/trunk/src/Products/Sessions/ Use more canonical interface names; get real test coveage.

2009-05-11 Thread Tres Seaver
Log message for revision 99852:
  Use more canonical interface names; get real test coveage.

Changed:
  U   Zope/trunk/src/Products/Sessions/BrowserIdManager.py
  U   Zope/trunk/src/Products/Sessions/tests/testBrowserIdManager.py

-=-
Modified: Zope/trunk/src/Products/Sessions/BrowserIdManager.py
===
--- Zope/trunk/src/Products/Sessions/BrowserIdManager.py2009-05-11 
17:27:38 UTC (rev 99851)
+++ Zope/trunk/src/Products/Sessions/BrowserIdManager.py2009-05-11 
17:29:33 UTC (rev 99852)
@@ -43,7 +43,7 @@
 from ZPublisher.BeforeTraverse import queryBeforeTraverse
 from zope.interface import implements
 
-from Products.Sessions.SessionInterfaces import BrowserIdManagerInterface
+from Products.Sessions.SessionInterfaces import IBrowserIdManager
 from Products.Sessions.SessionPermissions import ACCESS_CONTENTS_PERM
 from Products.Sessions.SessionPermissions import CHANGE_IDMGR_PERM
 from Products.Sessions.SessionPermissions import MGMT_SCREEN_PERM
@@ -82,25 +82,15 @@
 if REQUEST is not None:
 return self.manage_main(self, REQUEST, update_menu=1)
 
-class BrowserIdManagerErr(Exception): pass
+class BrowserIdManagerErr(ValueError): # BBB
+pass
 
 class BrowserIdManager(Item, Persistent, Implicit, RoleManager, Owned, Tabs):
- browser id management class 
-
+ browser id management class
+
+implements(IBrowserIdManager)
 meta_type = 'Browser Id Manager'
 
-manage_options=(
-{'label': 'Settings',
- 'action':'manage_browseridmgr',
- },
-{'label': 'Security', 'action':'manage_access'},
-{'label': 'Ownership', 'action':'manage_owner'}
-)
-
-implements(BrowserIdManagerInterface)
-
-icon = 'misc_/Sessions/idmgr.gif'
-
 security = ClassSecurityInfo()
 security.declareObjectPublic()
 ok = {'meta_type':1, 'id':1, 'title': 1, 'icon':1,
@@ -110,7 +100,7 @@
 security.setPermissionDefault(ACCESS_CONTENTS_PERM,['Manager','Anonymous'])
 security.setPermissionDefault(CHANGE_IDMGR_PERM, ['Manager'])
 
-# backwards-compatibility for pre-2.6 instances
+# BBB
 auto_url_encoding = 0
 
 def __init__(self, id, title='', idname='_ZopeId',
@@ -128,31 +118,20 @@
 self.setCookieHTTPOnly(cookiehttponly)
 self.setAutoUrlEncoding(auto_url_encoding)
 
-def manage_afterAdd(self, item, container):
- Maybe add our traversal hook 
-self.updateTraversalData()
-
-def manage_beforeDelete(self, item, container):
- Remove our traversal hook if it exists 
-self.unregisterTraversalHook()
-
+# IBrowserIdManager
 security.declareProtected(ACCESS_CONTENTS_PERM, 'hasBrowserId')
 def hasBrowserId(self):
- Returns true if there is a current browser id, but does
-not create a browser id for the current request if one doesn't
-already exist 
-if self.getBrowserId(create=0): return 1
+ See IBrowserIdManager.
+
+try:
+return self.getBrowserId(create=0) is not None
+except BrowserIdManagerErr:
+return False
 
 security.declareProtected(ACCESS_CONTENTS_PERM, 'getBrowserId')
 def getBrowserId(self, create=1):
+ See IBrowserIdManager.
 
-Examines the request and hands back browser id value or
-None if no id exists.  If there is no browser id
-and if 'create' is true, create one.  If cookies are are
-an allowable id namespace and create is true, set one.  Stuff
-the id and the namespace it was found in into the REQUEST object
-for further reference during this request.
-
 REQUEST = self.REQUEST
 # let's see if bid has already been attached to request
 bid = getattr(REQUEST, 'browser_id_', None)
@@ -162,10 +141,9 @@
 if not isAWellFormedBrowserId(bid):
 # somebody screwed with the REQUEST instance during
 # this request.
-raise BrowserIdManagerErr, (
-'Ill-formed browserid in REQUEST.browser_id_:  %s' % 
-escape(bid)
-)
+raise BrowserIdManagerErr(
+'Ill-formed browserid in '
+'REQUEST.browser_id_:  %s' % escape(bid))
 return bid
 # fall through  ck form/cookie namespaces if bid is not in request.
 tk = self.browserid_name
@@ -196,71 +174,84 @@
 # implies a return of None if:
 # (not create=1) and (invalid or ((not in req) and (not in ns)))
 
-security.declareProtected(ACCESS_CONTENTS_PERM, 'flushBrowserIdCookie')
-def flushBrowserIdCookie(self):
- removes the bid cookie from the client browser 
-if 'cookies' not in self.browserid_namespaces:
-raise BrowserIdManagerErr,('Cookies are not now being used as a '
- 

[Zope-Checkins] SVN: Zope/trunk/src/Products/Sessions/Session Use more canonical interface names.

2009-05-11 Thread Tres Seaver
Log message for revision 99851:
  Use more canonical interface names.

Changed:
  U   Zope/trunk/src/Products/Sessions/SessionDataManager.py
  U   Zope/trunk/src/Products/Sessions/SessionInterfaces.py

-=-
Modified: Zope/trunk/src/Products/Sessions/SessionDataManager.py
===
--- Zope/trunk/src/Products/Sessions/SessionDataManager.py  2009-05-11 
16:53:37 UTC (rev 99850)
+++ Zope/trunk/src/Products/Sessions/SessionDataManager.py  2009-05-11 
17:27:38 UTC (rev 99851)
@@ -32,7 +32,7 @@
 from ZODB.POSException import ConflictError
 from zope.interface import implements
 
-from Products.Sessions.SessionInterfaces import SessionDataManagerInterface
+from Products.Sessions.SessionInterfaces import ISessionDataManager
 from Products.Sessions.SessionPermissions import ACCESS_CONTENTS_PERM
 from Products.Sessions.SessionPermissions import ACCESS_SESSIONDATA_PERM
 from Products.Sessions.SessionPermissions import ARBITRARY_SESSIONDATA_PERM
@@ -93,7 +93,7 @@
 
 icon='misc_/CoreSessionTracking/datamgr.gif'
 
-implements(SessionDataManagerInterface)
+implements(ISessionDataManager)
 
 manage_sessiondatamgr = DTMLFile('dtml/manageDataManager',
 globals())

Modified: Zope/trunk/src/Products/Sessions/SessionInterfaces.py
===
--- Zope/trunk/src/Products/Sessions/SessionInterfaces.py   2009-05-11 
16:53:37 UTC (rev 99850)
+++ Zope/trunk/src/Products/Sessions/SessionInterfaces.py   2009-05-11 
17:27:38 UTC (rev 99851)
@@ -10,48 +10,52 @@
 # FOR A PARTICULAR PURPOSE
 #
 
-
+ Session APIs
 
-Session APIs
+o See Also
 
-  See Also
-
 - Transient Object API:../../Transience/Help/TransienceInterfaces.py
 
 
 
 from zope.interface import Interface
 
-class BrowserIdManagerInterface(Interface):
-
-Zope Browser Id Manager interface.
+class IBrowserIdManager(Interface):
+ Zope Browser Id Manager interface.
 
 A Zope Browser Id Manager is responsible for assigning ids to site
 visitors, and for servicing requests from Session Data Managers
 related to the browser id.
 
-def encodeUrl(url, style='querystring'):
-
-Encodes a provided URL with the current request's browser id
-and returns the result.  Two forms of URL-encoding are supported:
-'querystring' and 'inline'.  'querystring' is the default.
+def hasBrowserId():
+ Return true if there is a browser id for the current request.
 
-If the 'querystring' form is used, the browser id name/value pair
-are postfixed onto the URL as a query string.  If the 'inline'
-form is used, the browser id name/value pair are prefixed onto
-the URL as the first two path segment elements.
+o Permission required: Access contents information
 
-For example:
+o Does *not* raise an error if the request contains a broken
+  browser id.
+
 
- The call encodeUrl('http://foo.com/amethod', style='querystring')
- might return 'http://foo.com/amethod?_ZopeId=as9dfu0adfu0ad'.
+def getBrowserId(create=1):
+ Return a browser id for the current request.
 
- The call encodeUrl('http://foo.com/amethod, style='inline')
- might return 'http://foo.com/_ZopeId/as9dfu0adfu0ad/amethod'.
+o If create is false, return None if there is no browser id associated
+  with the current request.
+  
+o If create is true, return a newly-created browser id if
+  there is no browser id associated with the current request.
+  
+o This method is useful in conjunction with 'getBrowserIdName' if you
+  wish to embed the browser-id-name/browser-id combination as a hidden
+  value in a POST-based form.
+  
+o The browser id is opaque, has no business meaning, and its length,
+  type, and composition are subject to change.
 
-Permission required: Access contents information
+o Permission required: Access contents information
 
-Raises:  BrowserIdManagerErr.  If there is no current browser id.
+o Raises BrowserIdManagerErr if an ill-formed browser id
+  is found in REQUEST.
 
 
 def getBrowserIdName():
@@ -63,30 +67,6 @@
 Permission required: Access contents information
 
 
-def getBrowserId(create=1):
-
-If create=0, returns a the current browser id or None if there
-is no browser id associated with the current request.  If create=1,
-returns the current browser id or a newly-created browser id if
-there is no browser id associated with the current request.  This
-method is useful in conjunction with getBrowserIdName if you wish to
-embed the browser-id-name/browser-id combination as a hidden 

[Zope-Checkins] SVN: Zope/trunk/ Fix BBB regression which prevented setting browser ID cookies

2009-05-11 Thread Tres Seaver
Log message for revision 99853:
  Fix BBB regression which prevented setting browser ID cookies
  
  . Browser ID managers created before the 'HTTPOnly' feature landed didn't
have a 'cookie_httponly' attribute.  https://bugs.launchpad.net/bugs/374816
  

Changed:
  U   Zope/trunk/doc/CHANGES.rst
  U   Zope/trunk/src/Products/Sessions/BrowserIdManager.py
  U   Zope/trunk/src/Products/Sessions/tests/testBrowserIdManager.py

-=-
Modified: Zope/trunk/doc/CHANGES.rst
===
--- Zope/trunk/doc/CHANGES.rst  2009-05-11 17:29:33 UTC (rev 99852)
+++ Zope/trunk/doc/CHANGES.rst  2009-05-11 17:35:59 UTC (rev 99853)
@@ -5,9 +5,37 @@
 Change information for previous versions of Zope can be found in the
 file HISTORY.txt.
 
-Trunk (2009/05/06)
+Trunk (unreleased)
 --
 
+Features Added
+++
+
+- zExceptions.convertExceptionType:  new API, breaking out conversion of
+  exception names to exception types from 'upgradeException'.
+
+Bugs Fixed
+++
+
+- Fix BBB regression which prevented setting browser ID cookies from
+  browser ID managers created before the 'HTTPOnly' feature landed.
+  https://bugs.launchpad.net/bugs/374816
+
+- RESPONSE.handle_errors was wrongly set (to debug, should have been
+  ``not debug``). Also, the check for exception constructor arguments
+  didn't account for exceptions that didn't override the ``__init__``
+  (which are most of them). The combination of those two problems
+  caused the ``standard_error_message`` not to be called. Fixes
+  https://bugs.launchpad.net/zope2/+bug/372632 .
+
+- DocumentTemplate.DT_Raise:  use new 'zExceptions.convertExceptionType'
+  API to allow raising non-builtin exceptions.
+  Fixes https://bugs.launchpad.net/zope2/+bug/372629 , which prevented
+  viewing the Try tab of a script with no parameters.
+
+Zope 2.12.0b1 (2009/05/06)
+--
+
 Restructuring
 +
 
@@ -23,9 +51,6 @@
 Features Added
 ++
 
-- zExceptions.convertExceptionType:  new API, breaking out conversion of
-  exception names to exception types from 'upgradeException'.
-
 - Extended BrowserIdManager to expose the 'HTTPOnly' attribute for its
   cookie. Also via https://bugs.launchpad.net/zope2/+bug/367393 .
 
@@ -36,18 +61,6 @@
 Bugs Fixed
 ++
 
-- RESPONSE.handle_errors was wrongly set (to debug, should have been
-  ``not debug``). Also, the check for exception constructor arguments
-  didn't account for exceptions that didn't override the ``__init__``
-  (which are most of them). The combination of those two problems
-  caused the ``standard_error_message`` not to be called. Fixes
-  https://bugs.edge.launchpad.net/zope2/+bug/372632 .
-
-- DocumentTemplate.DT_Raise:  use new 'zExceptions.convertExceptionType'
-  API to allow raising non-builtin exceptions.
-  Fixes https://bugs.launchpad.net/zope2/+bug/372629 , which prevented
-  viewing the Try tab of a script with no parameters.
-
 - ZPublisher response.setBody: don't append Accept-Encoding to Vary header if
   it is already present - this can make cache configuration difficult.
 

Modified: Zope/trunk/src/Products/Sessions/BrowserIdManager.py
===
--- Zope/trunk/src/Products/Sessions/BrowserIdManager.py2009-05-11 
17:29:33 UTC (rev 99852)
+++ Zope/trunk/src/Products/Sessions/BrowserIdManager.py2009-05-11 
17:35:59 UTC (rev 99853)
@@ -102,6 +102,7 @@
 
 # BBB
 auto_url_encoding = 0
+cookie_http_only = 0
 
 def __init__(self, id, title='', idname='_ZopeId',
  location=('cookies', 'form'), cookiepath=('/'),

Modified: Zope/trunk/src/Products/Sessions/tests/testBrowserIdManager.py
===
--- Zope/trunk/src/Products/Sessions/tests/testBrowserIdManager.py  
2009-05-11 17:29:33 UTC (rev 99852)
+++ Zope/trunk/src/Products/Sessions/tests/testBrowserIdManager.py  
2009-05-11 17:35:59 UTC (rev 99853)
@@ -451,6 +451,17 @@
 self.assertEqual(response.cookies['bid'],
  {'path': '/', 'value': 'xxx', 'http_only': True})
 
+def test__setCookie_http_only_missing_attr(self):
+# See https://bugs.launchpad.net/bugs/374816
+response = DummyResponse(cookies={})
+request = DummyRequest(RESPONSE=response, URL1='https://example.com/')
+mgr = self._makeOne(request)
+del mgr.cookie_http_only # pre-2.12 instances didn't have this
+mgr.setBrowserIdName('bid')
+mgr._setCookie('xxx', request)
+self.assertEqual(response.cookies['bid'],
+ {'path': '/', 'value': 'xxx'})
+
 def test__setId_same_id_noop(self):
 mgr = self._makeOne(name='foo')
 mgr._setId('foo')

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


[Zope-Checkins] SVN: Zope/trunk/versions.cfg Update to bugfix release zope.app.form = 3.7.3

2009-05-11 Thread Hanno Schlichting
Log message for revision 99855:
  Update to bugfix release zope.app.form = 3.7.3
  

Changed:
  U   Zope/trunk/versions.cfg

-=-
Modified: Zope/trunk/versions.cfg
===
--- Zope/trunk/versions.cfg 2009-05-11 18:27:40 UTC (rev 99854)
+++ Zope/trunk/versions.cfg 2009-05-11 18:49:48 UTC (rev 99855)
@@ -46,7 +46,7 @@
 zope.app.exception = 3.5.0
 zope.app.file = 3.5.0
 zope.app.folder = 3.5.1
-zope.app.form = 3.7.2
+zope.app.form = 3.7.3
 zope.app.generations = 3.5.0
 zope.app.http = 3.5.2
 zope.app.i18n = 3.6.0

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