Skip to content

Commit

Permalink
Zope2 and Products.ZCatalog both need name_trans for now.
Browse files Browse the repository at this point in the history
We could copy the name_trans function to those packages instead,
but it seems fine to me to keep it here.
  • Loading branch information
tschorr authored and mauritsvanrees committed Feb 1, 2017
1 parent b504b22 commit ab35059
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/AccessControl/Permission.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
"""

from Acquisition import aq_base
import string
import re

_NOT_ALLOWED_CHARS = re.compile(r'[^a-zA-Z0-9_]')


name_trans = filter(
lambda c,
an=string.letters + string.digits + '_': c not in an,
map(chr, range(256)))
name_trans = string.maketrans(''.join(name_trans), '_' * len(name_trans))


def getPermissionIdentifier(name):
return '_' + re.sub(_NOT_ALLOWED_CHARS, '_', name) + "_Permission"

Expand Down

0 comments on commit ab35059

Please sign in to comment.