[CMF-checkins] CVS: CMF/CMFCore - CatalogTool.py:1.30.4.3 FSSTXMethod.py:1.5.36.1 RegistrationTool.py:1.13.4.1 __init__.py:1.15.8.1 utils.py:1.23.4.3
Tres Seaver
tseaver@zope.com
Sun, 21 Jul 2002 19:50:37 -0400
Update of /cvs-repository/CMF/CMFCore
In directory cvs.zope.org:/tmp/cvs-serv29928/CMFCore
Modified Files:
Tag: CMF-1_3-branch
CatalogTool.py FSSTXMethod.py RegistrationTool.py __init__.py
utils.py
Log Message:
- CatalogTool.py:
o Accomodate utility function renaming.
- FSSTXMethod.py:
o Accomodate utility function renaming.
o Normalize imports, permission usage.
- RegistrationTool.py:
o Accomodate utility function renaming.
o Normalize imports, permission usage.
- __init__.py:
o Make explicit module security assertions, enabling scripting
access to 'utils'.
- utils.py:
o Rename private functions to start with '_'.
o Rename public functions not to.
o Make explicit ModuleSecurityInfo assertions in accordance.
=== CMF/CMFCore/CatalogTool.py 1.30.4.2 => 1.30.4.3 ===
from string import join
from AccessControl.PermissionRole import rolesForPermissionOn
from AccessControl import ClassSecurityInfo
-from utils import mergedLocalRoles
+from utils import _mergedLocalRoles
from ActionProviderBase import ActionProviderBase
from ActionInformation import ActionInformation
from Expression import Expression
@@ -57,7 +57,7 @@
allowed = {}
for r in rolesForPermissionOn('View', ob):
allowed[r] = 1
- localroles = mergedLocalRoles(ob)
+ localroles = _mergedLocalRoles(ob)
for user, roles in localroles.items():
for role in roles:
if allowed.has_key(role):
=== CMF/CMFCore/FSSTXMethod.py 1.5 => 1.5.36.1 ===
#
##############################################################################
"""FSSTXMethod: Filesystem methodish Structured Text document.
+
$Id$
"""
-__version__='$Revision$'[11:-2]
-
-from string import split
-from os import path, stat
-import re
import Globals
-from AccessControl import ClassSecurityInfo, getSecurityManager, Permissions
-from OFS.DTMLMethod import DTMLMethod, decapitate, guess_content_type
-
-from utils import _dtmldir, _format_stx
-import CMFCorePermissions
+from AccessControl import ClassSecurityInfo
import StructuredText
-from DirectoryView import registerFileExtension, registerMetaType, expandpath
+
+from DirectoryView import registerFileExtension
+from DirectoryView import registerMetaType
+from DirectoryView import expandpath
from FSObject import FSObject
+from CMFCorePermissions import View
+from CMFCorePermissions import ViewManagementScreens
+from CMFCorePermissions import FTPAccess
+
+from utils import _dtmldir
+from utils import format_stx
+
class FSSTXMethod( FSObject ):
"""
@@ -50,10 +52,9 @@
)
security = ClassSecurityInfo()
- security.declareObjectProtected( CMFCorePermissions.View )
+ security.declareObjectProtected( View )
- security.declareProtected( CMFCorePermissions.ViewManagementScreens
- , 'manage_main')
+ security.declareProtected( ViewManagementScreens, 'manage_main')
manage_main = Globals.DTMLFile( 'custstx', _dtmldir )
#
@@ -101,7 +102,7 @@
def cook( self ):
if not hasattr( self, '_v_cooked' ):
- self._v_cooked = _format_stx( text=self.raw )
+ self._v_cooked = format_stx( text=self.raw )
return self._v_cooked
_default_template = Globals.HTML( """\
@@ -136,14 +137,14 @@
return apply( template, posargs, { 'cooked' : self.cook() } )
- security.declareProtected( CMFCorePermissions.FTPAccess, 'manage_FTPget' )
+ security.declareProtected( FTPAccess, 'manage_FTPget' )
def manage_FTPget( self ):
"""
Fetch our source for delivery via FTP.
"""
return self.raw
- security.declareProtected( CMFCorePermissions.ViewManagementScreens
+ security.declareProtected( ViewManagementScreens
, 'PrincipiaSearchSource' )
def PrincipiaSearchSource( self ):
"""
@@ -151,7 +152,7 @@
"""
return self.raw
- security.declareProtected( CMFCorePermissions.ViewManagementScreens
+ security.declareProtected( ViewManagementScreens
, 'document_src' )
def document_src( self ):
"""
=== CMF/CMFCore/RegistrationTool.py 1.13 => 1.13.4.1 ===
#
##############################################################################
-"""Basic user registration tool.
+""" Basic user registration tool.
+
$Id$
"""
-__version__='$Revision$'[11:-2]
-
-from utils import UniqueObject
-from utils import _checkPermission, _getAuthenticatedUser, limitGrantedRoles
-from utils import getToolByName, _dtmldir
+from Globals import InitializeClass
+from Globals import DTMLFile
from OFS.SimpleItem import SimpleItem
-from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
-from CMFCorePermissions import AddPortalMember, MailForgottenPassword, \
- SetOwnPassword, SetOwnProperties
-import CMFCorePermissions
-import string, random
+
from ActionProviderBase import ActionProviderBase
+from CMFCorePermissions import AddPortalMember
+from CMFCorePermissions import MailForgottenPassword
+from CMFCorePermissions import SetOwnPassword
+from CMFCorePermissions import SetOwnProperties
+from CMFCorePermissions import ManagePortal
+
+from utils import UniqueObject
+from utils import _checkPermission
+from utils import _getAuthenticatedUser
+from utils import _limitGrantedRoles
+from utils import getToolByName
+from utils import _dtmldir
+
+
+class RegistrationTool(UniqueObject, SimpleItem, ActionProviderBase):
-class RegistrationTool (UniqueObject, SimpleItem, ActionProviderBase):
- # This tool creates and modifies users by making calls
- # to portal_membership.
+ """ Create and modify users by making calls to portal_membership.
+ """
id = 'portal_registration'
meta_type = 'CMF Registration Tool'
@@ -46,7 +54,7 @@
#
# ZMI methods
#
- security.declareProtected( CMFCorePermissions.ManagePortal
+ security.declareProtected( ManagePortal
, 'manage_overview' )
manage_overview = DTMLFile( 'explainRegistrationTool', _dtmldir )
@@ -83,6 +91,7 @@
'''Generates a password which is guaranteed to comply
with the password policy.
'''
+ import string, random
chars = string.lowercase[:26] + string.uppercase[:26] + string.digits
result = []
for n in range(6):
@@ -115,7 +124,7 @@
# Limit the granted roles.
# Anyone is always allowed to grant the 'Member' role.
- limitGrantedRoles(roles, self, ('Member',))
+ _limitGrantedRoles(roles, self, ('Member',))
membership = getToolByName(self, 'portal_membership')
membership.addMember(id, password, roles, domains, properties)
=== CMF/CMFCore/__init__.py 1.15 => 1.15.8.1 ===
import CachingPolicyManager
import utils
+from AccessControl import ModuleSecurityInfo
+
+prod_security = ModuleSecurityInfo( 'Products' )
+prod_security.declarePublic( 'CMFCore' )
+
+security = ModuleSecurityInfo( 'Products.CMFCore' )
+security.declarePublic( 'utils' )
+
try:
import FSPageTemplate
except ImportError:
=== CMF/CMFCore/utils.py 1.23.4.2 => 1.23.4.3 ===
_STXDWI = StructuredText.DocumentWithImages.__class__
+security = ModuleSecurityInfo( 'Products.CMFCore.utils' )
+
+security.declarePublic( 'getToolByName'
+ , 'cookString'
+ , 'tuplize'
+ , 'format_stx'
+ , 'keywordsplitter'
+ , 'normalize'
+ , 'expandpath'
+ , 'minimalpath'
+ )
+
+security.declarePrivate( '_getAuthenticatedUser'
+ , '_checkPermission'
+ , '_verifyActionPermissions'
+ , '_getViewFor'
+ , '_limitGrantedRoles'
+ , '_mergedLocalRoles'
+ , '_modifyPermissionMappings'
+ , '_ac_inherited_permissions'
+ )
+
_dtmldir = os_path.join( package_home( globals() ), 'dtml' )
@@ -146,7 +168,7 @@
# If Zope ever provides a call to getRolesInContext() through
# the SecurityManager API, the method below needs to be updated.
-def limitGrantedRoles(roles, context, special_roles=()):
+def _limitGrantedRoles(roles, context, special_roles=()):
# Only allow a user to grant roles already possessed by that user,
# with the exception that all special_roles can also be granted.
user = _getAuthenticatedUser(context)
@@ -161,7 +183,9 @@
if role not in special_roles and role not in user_roles:
raise 'Unauthorized', 'Too many roles specified.'
-def mergedLocalRoles(object):
+limitGrantedRoles = _limitGrantedRoles # XXX: Deprecated spelling
+
+def _mergedLocalRoles(object):
"""Returns a merging of object and its ancestors'
__ac_local_roles__."""
# Modified from AccessControl.User.getRolesInContext().
@@ -187,7 +211,9 @@
break
return merged
-def ac_inherited_permissions(ob, all=0):
+mergedLocalRoles = _mergedLocalRoles # XXX: Deprecated spelling
+
+def _ac_inherited_permissions(ob, all=0):
# Get all permissions not defined in ourself that are inherited
# This will be a sequence of tuples with a name as the first item and
# an empty tuple as the second.
@@ -205,14 +231,14 @@
r = list(perms) + r
return r
-def modifyPermissionMappings(ob, map):
+def _modifyPermissionMappings(ob, map):
"""
Modifies multiple role to permission mappings.
"""
# This mimics what AccessControl/Role.py does.
# Needless to say, it's crude. :-(
something_changed = 0
- perm_info = ac_inherited_permissions(ob, 1)
+ perm_info = _ac_inherited_permissions(ob, 1)
for name, settings in map.items():
cur_roles = rolesForPermissionOn(name, ob)
t = type(cur_roles)
@@ -553,7 +579,7 @@
CMFHtmlWithImages = CMFHtmlWithImages()
-def _format_stx( text, level=1 ):
+def format_stx( text, level=1 ):
"""
Render STX to HTML.
"""
@@ -564,6 +590,8 @@
doc = CMFDocumentClass( st )
html = CMFHtmlWithImages( doc, level )
return html
+
+_format_stx = format_stx # XXX: Deprecated spelling
#
# Metadata Keyword splitter utilities