[Checkins] SVN: zope.locking/trunk/src/zope/locking/ The generation added in 1.2 didn't go far enough in cleaning up token utilities
Patrick Strawderman
patrick at zope.com
Wed Jan 20 10:29:21 EST 2010
Log message for revision 108330:
The generation added in 1.2 didn't go far enough in cleaning up token utilities
Changed:
U zope.locking/trunk/src/zope/locking/CHANGES.txt
U zope.locking/trunk/src/zope/locking/generations.py
-=-
Modified: zope.locking/trunk/src/zope/locking/CHANGES.txt
===================================================================
--- zope.locking/trunk/src/zope/locking/CHANGES.txt 2010-01-20 15:09:39 UTC (rev 108329)
+++ zope.locking/trunk/src/zope/locking/CHANGES.txt 2010-01-20 15:29:21 UTC (rev 108330)
@@ -7,7 +7,15 @@
----------------
+------------------
+1.2.1 (2010-01-20)
+------------------
+- Bug fix: the generation added in 1.2 did not properly clean up
+ expired tokens, and could leave the token utility in an inconsistent
+ state.
+
+
----------------
1.2 (2009-11-23)
----------------
Modified: zope.locking/trunk/src/zope/locking/generations.py
===================================================================
--- zope.locking/trunk/src/zope/locking/generations.py 2010-01-20 15:09:39 UTC (rev 108329)
+++ zope.locking/trunk/src/zope/locking/generations.py 2010-01-20 15:29:21 UTC (rev 108330)
@@ -3,14 +3,15 @@
import zope.app.generations.interfaces
import zope.locking.interfaces
+import zope.locking.utils
class SchemaManager(object):
zope.interface.implements(
zope.app.generations.interfaces.IInstallableSchemaManager)
- minimum_generation = 1
- generation = 1
+ minimum_generation = 2
+ generation = 2
def install(self, context):
# Clean up cruft in any existing token utilities.
@@ -22,7 +23,13 @@
fix_token_utility(util)
def evolve(self, context, generation):
- pass
+ if generation == 2:
+ # Going from generation 1 -> 2, we need to run the token
+ # utility fixer again because of a deficiency it had in 1.2.
+ app = context.connection.root().get('Application')
+ if app is not None:
+ for util in find_token_utilities(app):
+ fix_token_utility(util)
schemaManager = SchemaManager()
@@ -58,5 +65,18 @@
util._principal_ids[pid] = new_tree
else:
del util._principal_ids[pid]
+ now = zope.locking.utils.now()
for dt, tree in list(util._expirations.items()):
- util._expirations[dt] = BTrees.OOBTree.OOTreeSet(tree)
+ if dt > now:
+ util._expirations[dt] = BTrees.OOBTree.OOTreeSet(tree)
+ else:
+ del util._expirations[dt]
+ for token in tree:
+ # Okay, we could just adapt token.context to IKeyReference
+ # here...but we don't want to touch token.context,
+ # because some wonky objects need a site set before
+ # they can be unpickled.
+ for key_ref, (_token, _, _) in list(util._locks.items()):
+ if token is _token:
+ del util._locks[key_ref]
+ break
More information about the checkins
mailing list