Skip to content

Commit

Permalink
More fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
hannosch committed May 3, 2017
1 parent 7a4b23d commit b43f84d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/Testing/ZopeTestCase/testZopeTestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from AccessControl import getSecurityManager
from Acquisition import aq_base
from OFS.userfolder import UserFolder
from types import ListType

from Testing import ZopeTestCase
from Testing.ZopeTestCase import folder_name
Expand Down Expand Up @@ -91,7 +90,7 @@ def test_setupUser(self):
acl_user = self.folder.acl_users.getUserById(user_name)
self.assertTrue(acl_user)
self.assertEqual(acl_user.getRoles(), (user_role, 'Authenticated'))
self.assertEqual(type(acl_user.roles), ListType)
self.assertEqual(type(acl_user.roles), list)

def test_setRoles(self):
# Roles should be set for user
Expand Down Expand Up @@ -253,7 +252,7 @@ def test_setUp(self):
acl_user = self.folder.acl_users.getUserById(user_name)
self.assertTrue(acl_user)
self.assertEqual(acl_user.getRoles(), (user_role, 'Authenticated'))
self.assertEqual(type(acl_user.roles), ListType)
self.assertEqual(type(acl_user.roles), list)
auth_name = getSecurityManager().getUser().getId()
self.assertEqual(auth_name, user_name)
self.assertEqual(self._called, ['beforeSetUp', 'afterSetUp'])
Expand Down
14 changes: 6 additions & 8 deletions src/ZTUtils/Tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
"""

import base64
from string import translate, maketrans
import zlib

from Acquisition import Explicit
from ComputedAttribute import ComputedAttribute
from types import ListType, TupleType


class TreeNode(Explicit):
Expand Down Expand Up @@ -214,8 +212,8 @@ def getChildren(self, object):
return self._values_function(object)

children = getattr(object, self._values)
if not (isinstance(children, ListType) or
isinstance(children, TupleType)):
if not (isinstance(children, list) or
isinstance(children, tuple)):
# Assume callable; result not useful anyway otherwise.
children = children()

Expand All @@ -233,21 +231,21 @@ def simple_type(ob,
return is_simple(type(ob))


a2u_map = maketrans('+/=', '-._')
u2a_map = maketrans('-._', '+/=')
a2u_map = str.maketrans('+/=', '-._')
u2a_map = str.maketrans('-._', '+/=')


def b2a(s):
'''Encode a value as a cookie- and url-safe string.
Encoded string use only alpahnumeric characters, and "._-".
'''
return translate(base64.encodestring(str(s)), a2u_map).replace('\n', '')
return base64.encodestring(str(s).translate(a2u_map)).replace('\n', '')


def a2b(s):
'''Decode a b2a-encoded string.'''
return base64.decodestring(translate(s, u2a_map))
return base64.decodestring(s.translate(u2a_map))


def encodeExpansion(nodes, compress=1):
Expand Down

0 comments on commit b43f84d

Please sign in to comment.