Commit b6c7f455 authored by Andreas Jung's avatar Andreas Jung

merge from 2.5 branch (string methods)

parent 5590459c
...@@ -11,11 +11,10 @@ ...@@ -11,11 +11,10 @@
# #
############################################################################## ##############################################################################
__version__='$Revision: 1.5 $'[11:-2] __version__='$Revision: 1.6 $'[11:-2]
import sha, binascii import sha, binascii
from binascii import b2a_base64, a2b_base64 from binascii import b2a_base64, a2b_base64
from string import upper
from random import choice, randrange from random import choice, randrange
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
__doc__='''Support for owned objects __doc__='''Support for owned objects
$Id: Owned.py,v 1.14 2001/11/28 15:50:51 matt Exp $''' $Id: Owned.py,v 1.15 2001/12/13 14:24:02 andreasjung Exp $'''
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
import Globals, urlparse, SpecialUsers, ExtensionClass, string import Globals, urlparse, SpecialUsers, ExtensionClass
from AccessControl import getSecurityManager, Unauthorized from AccessControl import getSecurityManager, Unauthorized
from Acquisition import aq_get, aq_parent, aq_base from Acquisition import aq_get, aq_parent, aq_base
...@@ -54,7 +54,7 @@ class Owned(ExtensionClass.Base): ...@@ -54,7 +54,7 @@ class Owned(ExtensionClass.Base):
""" """
owner=self.getOwner(1) owner=self.getOwner(1)
if owner is None or owner is UnownableOwner: return owner if owner is None or owner is UnownableOwner: return owner
d={'path': string.join(owner[0], '/'), 'id': owner[1], d={'path': '/'.join(owner[0]), 'id': owner[1],
'explicit': hasattr(self, '_owner'), 'explicit': hasattr(self, '_owner'),
'userCanChangeOwnershipType': 'userCanChangeOwnershipType':
getSecurityManager().checkPermission('Take ownership', self) getSecurityManager().checkPermission('Take ownership', self)
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
__doc__='''short description __doc__='''short description
$Id: Permission.py,v 1.8 2001/11/28 15:50:51 matt Exp $''' $Id: Permission.py,v 1.9 2001/12/13 14:24:26 andreasjung Exp $'''
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
import string, Products, Globals import string, Products, Globals
...@@ -22,7 +22,7 @@ ListType=type([]) ...@@ -22,7 +22,7 @@ ListType=type([])
name_trans=filter(lambda c, an=string.letters+string.digits+'_': c not in an, name_trans=filter(lambda c, an=string.letters+string.digits+'_': c not in an,
map(chr,range(256))) map(chr,range(256)))
name_trans=string.maketrans(string.join(name_trans,''), '_'*len(name_trans)) name_trans=string.maketrans(''.join(name_trans), '_'*len(name_trans))
def pname(name, translate=string.translate, name_trans=name_trans): def pname(name, translate=string.translate, name_trans=name_trans):
return '_'+translate(name,name_trans)+"_Permission" return '_'+translate(name,name_trans)+"_Permission"
......
...@@ -117,7 +117,7 @@ class PM(ExtensionClass.Base): ...@@ -117,7 +117,7 @@ class PM(ExtensionClass.Base):
def __getattr__(self, name): def __getattr__(self, name):
# We want to make sure that any non-explicitly set methods are # We want to make sure that any non-explicitly set methods are
# private! # private!
if name[:1]=='_' and name[-11:]=="_Permission": return '' if name.startswith('_') and name.endswith("_Permission"): return ''
raise AttributeError, name raise AttributeError, name
PermissionMapper=PM PermissionMapper=PM
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
__doc__='''Objects that implement Permission-based roles. __doc__='''Objects that implement Permission-based roles.
$Id: PermissionRole.py,v 1.14 2001/11/28 15:50:51 matt Exp $''' $Id: PermissionRole.py,v 1.15 2001/12/13 14:24:41 andreasjung Exp $'''
__version__='$Revision: 1.14 $'[11:-2] __version__='$Revision: 1.15 $'[11:-2]
_use_python_impl = 0 _use_python_impl = 0
import os import os
...@@ -40,7 +40,7 @@ if _use_python_impl: ...@@ -40,7 +40,7 @@ if _use_python_impl:
name_trans=filter(lambda c, an=string.letters+string.digits+'_': c not in an, name_trans=filter(lambda c, an=string.letters+string.digits+'_': c not in an,
map(chr,range(256))) map(chr,range(256)))
name_trans=string.maketrans(string.join(name_trans,''), '_'*len(name_trans)) name_trans=string.maketrans(''.join(name_trans), '_'*len(name_trans))
def rolesForPermissionOn(perm, object, default=('Manager',)): def rolesForPermissionOn(perm, object, default=('Manager',)):
"""Return the roles that have the given permission on the given object """Return the roles that have the given permission on the given object
......
...@@ -12,11 +12,10 @@ ...@@ -12,11 +12,10 @@
############################################################################## ##############################################################################
"""Access control support""" """Access control support"""
__version__='$Revision: 1.52 $'[11:-2] __version__='$Revision: 1.53 $'[11:-2]
from Globals import DTMLFile, MessageDialog, Dictionary from Globals import DTMLFile, MessageDialog, Dictionary
from string import join, strip, split, find
from Acquisition import Implicit, Acquired, aq_get from Acquisition import Implicit, Acquired, aq_get
import Globals, ExtensionClass, PermissionMapping, Products import Globals, ExtensionClass, PermissionMapping, Products
from Permission import Permission from Permission import Permission
...@@ -209,7 +208,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -209,7 +208,7 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
if fails: if fails:
return MessageDialog(title="Warning!", return MessageDialog(title="Warning!",
message="Some permissions had errors: " message="Some permissions had errors: "
+ join(fails, ', '), + ', '.join(fails),
action='manage_access') action='manage_access')
return MessageDialog( return MessageDialog(
title ='Success!', title ='Success!',
...@@ -380,13 +379,13 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager): ...@@ -380,13 +379,13 @@ class RoleManager(ExtensionClass.Base, PermissionMapping.RoleManager):
data=[] data=[]
_add=data.append _add=data.append
for key, value in inst.items(): for key, value in inst.items():
if find(key,'__roles__') >= 0: if key.find('__roles__') >= 0:
_add({'name': key, 'value': value, 'class': 0}) _add({'name': key, 'value': value, 'class': 0})
if hasattr(value, '__roles__'): if hasattr(value, '__roles__'):
_add({'name': '%s.__roles__' % key, 'value': value.__roles__, _add({'name': '%s.__roles__' % key, 'value': value.__roles__,
'class': 0}) 'class': 0})
for key, value in clas.items(): for key, value in clas.items():
if find(key,'__roles__') >= 0: if key.find('__roles__') >= 0:
_add({'name': key, 'value': value, 'class' : 1}) _add({'name': key, 'value': value, 'class' : 1})
if hasattr(value, '__roles__'): if hasattr(value, '__roles__'):
_add({'name': '%s.__roles__' % key, 'value': value.__roles__, _add({'name': '%s.__roles__' % key, 'value': value.__roles__,
......
...@@ -42,7 +42,6 @@ __version__='$Revision$'[11:-2] ...@@ -42,7 +42,6 @@ __version__='$Revision$'[11:-2]
import Acquisition, PermissionRole, sys import Acquisition, PermissionRole, sys
from string import lower
from zLOG import LOG, WARNING from zLOG import LOG, WARNING
...@@ -127,7 +126,7 @@ class SecurityInfo(Acquisition.Implicit): ...@@ -127,7 +126,7 @@ class SecurityInfo(Acquisition.Implicit):
booleans, or a callable (name, value) -> boolean. booleans, or a callable (name, value) -> boolean.
""" """
if type(access) == type(''): if type(access) == type(''):
access = lower(access) access = access.lower()
if access == 'allow': if access == 'allow':
access = 1 access = 1
elif access == 'deny': elif access == 'deny':
......
...@@ -13,14 +13,14 @@ ...@@ -13,14 +13,14 @@
__doc__='''short description __doc__='''short description
$Id: SecurityManager.py,v 1.11 2001/11/28 15:50:51 matt Exp $''' $Id: SecurityManager.py,v 1.12 2001/12/13 14:23:44 andreasjung Exp $'''
__version__='$Revision: 1.11 $'[11:-2] __version__='$Revision: 1.12 $'[11:-2]
import ZopeSecurityPolicy, os, string import ZopeSecurityPolicy, os
_noroles = ZopeSecurityPolicy._noroles _noroles = ZopeSecurityPolicy._noroles
try: max_stack_size=string.atoi(os.environ.get('Z_MAX_STACK_SIZE','100')) try: max_stack_size=int(os.environ.get('Z_MAX_STACK_SIZE','100'))
except: max_stack_size=100 except: max_stack_size=100
if os.environ.has_key("ZSP_OWNEROUS_SKIP"): ownerous=0 if os.environ.has_key("ZSP_OWNEROUS_SKIP"): ownerous=0
......
...@@ -12,12 +12,11 @@ ...@@ -12,12 +12,11 @@
############################################################################## ##############################################################################
"""Access control package""" """Access control package"""
__version__='$Revision: 1.165 $'[11:-2] __version__='$Revision: 1.166 $'[11:-2]
import Globals, socket, SpecialUsers,re import Globals, socket, SpecialUsers,re
import os import os
from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping from Globals import DTMLFile, MessageDialog, Persistent, PersistentMapping
from string import join, strip, split, lower, upper
from App.Management import Navigation, Tabs from App.Management import Navigation, Tabs
from Acquisition import Implicit from Acquisition import Implicit
from OFS.SimpleItem import Item from OFS.SimpleItem import Item
...@@ -399,9 +398,9 @@ def readUserAccessFile(filename): ...@@ -399,9 +398,9 @@ def readUserAccessFile(filename):
return None return None
if line: if line:
data = split(strip(line), ':') data = line.strip().split(':')
remote_user_mode = not data[1] remote_user_mode = not data[1]
try: ds = split(data[2], ' ') try: ds = data[2].split(' ')
except: ds = [] except: ds = []
return data[0], data[1], ds, remote_user_mode return data[0], data[1], ds, remote_user_mode
else: else:
...@@ -558,9 +557,9 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager, ...@@ -558,9 +557,9 @@ class BasicUserFolder(Implicit, Persistent, Navigation, Tabs, RoleManager,
def identify(self, auth): def identify(self, auth):
if auth and lower(auth[:6])=='basic ': if auth and auth.lower().startswith('basic '):
try: name, password=tuple(split(decodestring( try: name, password=tuple(decodestring(
split(auth)[-1]), ':', 1)) auth.split(' ')[-1]).split(':', 1))
except: except:
raise 'Bad Request', 'Invalid authentication token' raise 'Bad Request', 'Invalid authentication token'
return name, password return name, password
...@@ -1125,14 +1124,14 @@ def domainSpecMatch(spec, request): ...@@ -1125,14 +1124,14 @@ def domainSpecMatch(spec, request):
except: pass except: pass
_host=split(host, '.') _host=host.split('.')
_addr=split(addr, '.') _addr=addr.split('.')
_hlen=len(_host) _hlen=len(_host)
_alen=len(_addr) _alen=len(_addr)
for ob in spec: for ob in spec:
sz=len(ob) sz=len(ob)
_ob=split(ob, '.') _ob=ob.split('.')
_sz=len(_ob) _sz=len(_ob)
mo = addr_match(ob) mo = addr_match(ob)
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
__doc__='''Define Zope\'s default security policy __doc__='''Define Zope\'s default security policy
$Id: ZopeSecurityPolicy.py,v 1.16 2001/11/28 15:50:52 matt Exp $''' $Id: ZopeSecurityPolicy.py,v 1.17 2001/12/13 14:25:19 andreasjung Exp $'''
__version__='$Revision: 1.16 $'[11:-2] __version__='$Revision: 1.17 $'[11:-2]
_use_python_impl = 0 _use_python_impl = 0
...@@ -85,7 +85,7 @@ if _use_python_impl: ...@@ -85,7 +85,7 @@ if _use_python_impl:
############################################################ ############################################################
# Provide special rules for the acquisition attributes # Provide special rules for the acquisition attributes
if type(name) is StringType: if type(name) is StringType:
if name[:3]=='aq_' and name not in valid_aq_: if name.startswith('aq_') and name not in valid_aq_:
return 0 return 0
containerbase = aq_base(container) containerbase = aq_base(container)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment