Skip to content

Commit

Permalink
fix imports and some syntax for py3
Browse files Browse the repository at this point in the history
  • Loading branch information
pbauer committed Mar 21, 2018
1 parent 194f245 commit 32cce53
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Products/Sessions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

def initialize(context):

import BrowserIdManager
import SessionDataManager
from . import BrowserIdManager
from . import SessionDataManager

context.registerClass(
BrowserIdManager.BrowserIdManager,
Expand Down
2 changes: 1 addition & 1 deletion src/Products/Transience/Fake.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def keys(self, min, max):
min = 0

if max is None:
max = sys.maxint
max = sys.maxsize

for k in self.data:
if min <= k <= max:
Expand Down
16 changes: 8 additions & 8 deletions src/Products/Transience/Transience.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def _all(self):
return d

def keys(self):
return self._all().keys()
return list(self._all().keys())

def raw(self, current_ts):
# for debugging and unit testing
Expand All @@ -398,10 +398,10 @@ def raw(self, current_ts):
return d

def items(self):
return self._all().items()
return list(self._all().items())

def values(self):
return self._all().values()
return list(self._all().values())

def _wrap(self, item):
# dont use hasattr here (it hides conflict errors)
Expand Down Expand Up @@ -961,7 +961,7 @@ def __setstate__(self, state):
# can't make __len__ an instance variable in new-style classes

# f/w compat: 2.8 cannot use __len__ as an instance variable
if not state.has_key('_length'):
if '_length' not in state:
length = state.get('__len__', Length2())
self._length = self.getLen = length

Expand All @@ -974,12 +974,12 @@ def __setstate__(self, state):
self._length = self.getLen = Length2(sz)

# TOCs prior to 2.7.1 took their period from a global
if not state.has_key('_period'):
if '_period' not in state:
self._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
if not state.has_key('_max_timeslice'):
if '_max_timeslice' not in state:
new_slices = getTimeslices(
getCurrentTimeslice(self._period),
SPARE_BUCKETS*2,
Expand All @@ -990,11 +990,11 @@ def __setstate__(self, state):
# create an Increaser for max timeslice
self._max_timeslice = Increaser(max(new_slices))

if not state.has_key('_last_finalized_timeslice'):
if '_last_finalized_timeslice' not in state:
self._last_finalized_timeslice = Increaser(-self._period)

# TOCs prior to 2.7.3 didn't have a _last_gc_timeslice
if not state.has_key('_last_gc_timeslice'):
if '_last_gc_timeslice' not in state:
self._last_gc_timeslice = Increaser(-self._period)

# we should probably delete older attributes from state such as
Expand Down
12 changes: 6 additions & 6 deletions src/Products/Transience/TransientObject.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,13 @@ def getContainerKey(self):
#

def keys(self):
return self._container.keys()
return list(self._container.keys())

def values(self):
return self._container.values()
return list(self._container.values())

def items(self):
return self._container.items()
return list(self._container.items())

def get(self, k, default=_notfound):
v = self._container.get(k, default)
Expand Down Expand Up @@ -207,7 +207,7 @@ def _p_resolveConflict(self, saved, state1, state2):
# We can clearly resolve the conflict if one state is invalid,
# because it's a terminal state.
for state in states:
if state.has_key('_invalid'):
if '_invalid' in state:
DEBUG and TLOG('TO _p_rc: a state was invalid')
return state

Expand Down Expand Up @@ -256,12 +256,12 @@ def _p_resolveConflict(self, saved, state1, state2):

def _generateUniqueId(self):
t = str(int(time.time()))
d = "%010d" % random.randint(0, sys.maxint-1)
d = "%010d" % random.randint(0, sys.maxsize-1)
return "%s%s" % (t, d)

def __repr__(self):
return "id: %s, token: %s, content keys: %r" % (
self.id, self.token, self.keys()
self.id, self.token, list(self.keys())
)

def lastmodified_sort(d1, d2):
Expand Down

0 comments on commit 32cce53

Please sign in to comment.