[Zope-Checkins] CVS: Products/Transience - Transience.py:1.32.12.10
Chris McDonough
chrism at plope.com
Sun Oct 10 22:41:18 EDT 2004
Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv30889
Modified Files:
Tag: Zope-2_7-branch
Transience.py
Log Message:
- Make TransientObjectContainer __setstate__ actually work. ;-)
Upgrades should be flawless from Zope 2.7.0, 2.7.1, and 2.7.2.
Upgrades from 2.6.3 will work, but data may not be retained.
- Added a "reset" button to the TOC management page and a reset
argument to the associated target method. This allows users
to decide to ditch the contents of their TOC and "start over".
It also has the effect of setting persistent objects which
cause the logic in __setstate__ to basically be a noop after
a single run.
- Added tests for manage_changeTOC and disabling inband gc.
- Changed default timeout for new TOCs to 60 seconds (this
is helpful to prevent certain classes of conflicts, see
http://www.plope.com/Members/dunny/conflicts for more info.
=== Products/Transience/Transience.py 1.32.12.9 => 1.32.12.10 ===
--- Products/Transience/Transience.py:1.32.12.9 Fri Sep 17 22:58:19 2004
+++ Products/Transience/Transience.py Sun Oct 10 22:40:48 2004
@@ -36,7 +36,6 @@
from Persistence import Persistent
from OFS.SimpleItem import SimpleItem
-from ZPublisher.Publish import Retry
from AccessControl import ClassSecurityInfo, getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager, \
setSecurityManager
@@ -44,7 +43,6 @@
from zLOG import LOG, WARNING, INFO
from TransientObject import TransientObject
-from Fake import FakeIOBTree
ADD_CONTAINER_PERM = 'Add Transient Object Container'
MGMT_SCREEN_PERM = 'View management screens'
@@ -79,7 +77,7 @@
'dtml/addTransientObjectContainer', globals())
def constructTransientObjectContainer(self, id, title='', timeout_mins=20,
- addNotification=None, delNotification=None, limit=0, period_secs=20,
+ addNotification=None, delNotification=None, limit=0, period_secs=60,
REQUEST=None):
""" """
ob = TransientObjectContainer(id, title, timeout_mins,
@@ -112,6 +110,7 @@
)
security = ClassSecurityInfo()
+ security.declareObjectProtected('View')
security.setPermissionDefault(MANAGE_CONTAINER_PERM,
['Manager',])
security.setPermissionDefault(MGMT_SCREEN_PERM,
@@ -142,7 +141,7 @@
gc_lock = thread.allocate_lock()
def __init__(self, id, title='', timeout_mins=20, addNotification=None,
- delNotification=None, limit=0, period_secs=20):
+ delNotification=None, limit=0, period_secs=60):
self.id = id
self.title=title
self._setTimeout(timeout_mins, period_secs)
@@ -244,10 +243,7 @@
# we need to maintain the length of the index structure separately
# because getting the length of a BTree is very expensive, and it
# doesn't really tell us which ones are "active" anyway.
- try:
- self._length.set(0)
- except AttributeError:
- self._length = self.getLen = Length2()
+ self._length = self.getLen = Length2()
def _getCurrentSlices(self, now):
if self._timeout_slices:
@@ -862,7 +858,7 @@
# TransientItemContainer methods
security.declareProtected(MANAGE_CONTAINER_PERM, 'setTimeoutMinutes')
- def setTimeoutMinutes(self, timeout_mins, period_secs=20):
+ def setTimeoutMinutes(self, timeout_mins, period_secs=20, reset=False):
""" The period_secs parameter is defaulted to preserve backwards API
compatibility. In older versions of this code, period was
hardcoded to 20. """
@@ -873,6 +869,10 @@
# do nothing unless something has changed
self._setTimeout(timeout_mins, period_secs)
self._reset()
+ elif reset:
+ # this is to facilitate upgrades (services the "reset" button
+ # on the management page).
+ self._reset()
def getTimeoutMinutes(self):
""" """
@@ -944,11 +944,17 @@
'manage_changeTransientObjectContainer')
def manage_changeTransientObjectContainer(
self, title='', timeout_mins=20, addNotification=None,
- delNotification=None, limit=0, period_secs=20, REQUEST=None
+ delNotification=None, limit=0, period_secs=60, do_toc_reset=False,
+ REQUEST=None
):
""" Change an existing transient object container. """
+ if do_toc_reset is not False:
+ # cope preventatively with browser checkbox issues
+ if do_toc_reset in ('off', 'no', 'false', ''):
+ do_toc_reset = False
+
self.title = title
- self.setTimeoutMinutes(timeout_mins, period_secs)
+ self.setTimeoutMinutes(timeout_mins, period_secs, do_toc_reset)
self.setSubobjectLimit(limit)
if not addNotification:
addNotification = None
@@ -963,6 +969,8 @@
)
def __setstate__(self, state):
+ SimpleItem.__setstate__(self, state)
+
# upgrade versions of Transience in Zope versions less
# than 2.7.1, which used a different transience mechanism. Note:
# this will not work for upgrading versions older than 2.6.0,
@@ -972,7 +980,7 @@
# f/w compat: 2.8 cannot use __len__ as an instance variable
if not state.has_key('_length'):
length = state.get('__len__', Length2())
- self._length = self.getLen = length
+ state['_length'] = self.getLen = length
oldlength = state['_length']
if isinstance(oldlength, BTreesLength):
@@ -980,11 +988,11 @@
# the TOC length object, replace it with our own Length2
# that does our conflict resolution correctly:
sz = oldlength()
- self._length = self.getLen = Length2(sz)
+ state['_length'] = self.getLen = Length2(sz)
# TOCs prior to 2.7.1 took their period from a global
if not state.has_key('_period'):
- self._period = 20 # this was the default for all prior releases
+ state['_period'] = 20 # this was the default for all prior releases
# TOCs prior to 2.7.1 used a different set of data structures
# for efficiently keeping tabs on the maximum slice
More information about the Zope-Checkins
mailing list