[Modeling-cvs] ZModeling/ZEditingContextSessioning README.txt,1.2,1.3 __init__.py,1.3,1.4
Status: Abandoned
Brought to you by:
sbigaret
From: <sbi...@us...> - 2003-09-07 11:03:34
|
Update of /cvsroot/modeling/ZModeling/ZEditingContextSessioning In directory sc8-pr-cvs1:/tmp/cvs-serv8276 Modified Files: README.txt __init__.py Log Message: SESSION's defaultEditingContext() can now automatically saveChanges() when a zope request/transaction ends: see README Index: README.txt =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZEditingContextSessioning/README.txt,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README.txt 6 May 2003 16:29:48 -0000 1.2 --- README.txt 7 Sep 2003 11:03:30 -0000 1.3 *************** *** 1,21 **** ! The ZEditingContextSessioning product adds a new method to Zope session ! objects: defaultEditingContext(), which delivers a specific EditingContext in ! each session. ! Creation, registration and deletion of a session's EC are managed ! Modeling.utilities.EditingContextSessioning. The unregistration and ! destruction of a session's EC is triggered by the session destruction --hence, ! there can be some time between the moment where the session expires and the ! actual unregistration/destruction of its EC. Installation - ------------ ! Simply drop ZEditingContextSessioning/ into a Zope's Products/ directory and ! restart zope. Documentation - ------------- ! The current documentation can be found in the User's Guide at: ! http://modeling.sourceforge.net/UserGuide/framework-integration-hints.html --- 1,32 ---- ! Overview ! The 'ZEditingContextSessioning' product adds a new method to Zope session ! objects: 'defaultEditingContext()', which delivers a specific ! 'EditingContext' in each session. ! ! 'EditingContext' 's and Zope's transactions ! ! By default, the delivered 'EditingContext' does not commit its transaction ! when Zope does. If you want that the session's 'EditingContext' ! 'saveChanges()' each time a zope request ends, click on the "Properties ! tab":manage_propertiesForm and check the box for property ! 'bind_saveChanges_to_zope_transactions' (then click on "Save Changes") ! ! Internals ! ! Creation, registration and deletion of a session's EC are managed ! 'Modeling.utilities.EditingContextSessioning'. The unregistration and ! destruction of a session's EC is triggered by the session destruction ! --hence, there can be some time between the moment where the session ! expires and the actual unregistration/destruction of its EC. Installation ! Simply drop 'ZEditingContextSessioning/' into a Zope's Products/ directory ! and restart zope. Documentation ! The current documentation can be found in the "User's ! Guide":http://modeling.sourceforge.net/UserGuide/framework-integration-hints.html. ! Index: __init__.py =================================================================== RCS file: /cvsroot/modeling/ZModeling/ZEditingContextSessioning/__init__.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** __init__.py 22 Apr 2003 09:36:50 -0000 1.3 --- __init__.py 7 Sep 2003 11:03:30 -0000 1.4 *************** *** 37,40 **** --- 37,62 ---- import zLOG + from Shared.DC.ZRDB.TM import TM + class ECProxy(TM): + def __init__(self, ec): + self.ec=ec + self._register() + + def _abort(self): + pass + + def _finish(self): + self.ec.lock() + self.ec.saveChanges() + self.ec.unlock() + + def _begin(self): + pass + + def __getattr__(self, n): + if hasattr(self.ec, n): + return getattr(self.ec, n) + raise ValueError + ## Implementation note: ## session.token was formerly used instead of session.id *************** *** 65,71 **** Returns the EditingContext bound to 'session' """ ! return EditingContextSessioning.getEditingContext(session.id) ! ! def initialize(context): """ --- 87,96 ---- Returns the EditingContext bound to 'session' """ ! product=session.Control_Panel.Products.ZEditingContextSessioning ! if product.bind_saveChanges_to_zope_transactions: ! return ECProxy(EditingContextSessioning.getEditingContext(session.id)) ! else: ! return EditingContextSessioning.getEditingContext(session.id) ! def initialize(context): """ *************** *** 94,97 **** --- 119,129 ---- sessionDataContainer.setDelNotificationTarget('/Control_Panel/Products/ZEditingContextSessioning/sessionDeletion_hook') + product=app.Control_Panel.Products.ZEditingContextSessioning + + bind_to_zope_txn='bind_saveChanges_to_zope_transactions' + if bind_to_zope_txn not in [p['id'] for p in product._properties]: + product.manage_addProperty(id=bind_to_zope_txn, + type='boolean', value=0) + # ?? Why did I need this? #context._ProductContext__prod.sessionDeletion_hook=sessionDeletion_hook |