[CMF-checkins] CVS: CMF/CMFDefault - DiscussionItem.py:1.28 DiscussionTool.py:1.11 Document.py:1.50 DublinCore.py:1.22 File.py:1.20 Image.py:1.18 Link.py:1.24 MetadataTool.py:1.17 NewsItem.py:1.16 PropertiesTool.py:1.8 SkinnedFolder.py:1.12 SyndicationTool.py:1.14 URLTool.py:1.12 utils.py:1.15
Florent Guillaume
fg@nuxeo.com
Sat, 3 Aug 2002 22:32:32 -0400
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv17343/CMFDefault
Modified Files:
DiscussionItem.py DiscussionTool.py Document.py DublinCore.py
File.py Image.py Link.py MetadataTool.py NewsItem.py
PropertiesTool.py SkinnedFolder.py SyndicationTool.py
URLTool.py utils.py
Log Message:
Pure stylistic and code formatting changes:
- Cleanup CMFCorePermissions imports.
- Always put security.declareProtected and friends on a single line
and just in front of the definition they're protecting, so that
automated coherency checking can be done using simple tools like
grep.
=== CMF/CMFDefault/DiscussionItem.py 1.27 => 1.28 ===
from OFS.Traversable import Traversable
from DateTime import DateTime
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import AccessContentsInformation
+from Products.CMFCore.CMFCorePermissions import ReplyToItem
+from Products.CMFCore.CMFCorePermissions import ManagePortal
from Products.CMFCore.utils import getToolByName
from Products.CMFCore.PortalContent import PortalContent
@@ -40,8 +43,7 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'discussionitem_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
,
)
@@ -99,7 +101,7 @@
security = ClassSecurityInfo()
- security.declareProtected( CMFCorePermissions.View, 'Creator' )
+ security.declareProtected(View, 'Creator')
def Creator( self ):
"""
We need to return user who replied, rather than executable
@@ -111,7 +113,7 @@
#
# DiscussionResponse interface
#
- security.declareProtected( CMFCorePermissions.View, 'inReplyTo' )
+ security.declareProtected(View, 'inReplyTo')
def inReplyTo( self, REQUEST=None ):
"""
Return the Discussable object to which we are a reply.
@@ -129,7 +131,7 @@
talkback = tool.getDiscussionFor( self )
return talkback._getReplyParent( self.in_reply_to )
- security.declarePrivate( CMFCorePermissions.View, 'setReplyTo' )
+ security.declarePrivate(View, 'setReplyTo')
def setReplyTo( self, reply_to ):
"""
Make this object a response to the passed object.
@@ -139,7 +141,7 @@
else:
self.in_reply_to = None
- security.declareProtected( CMFCorePermissions.View, 'parentsInThread' )
+ security.declareProtected(View, 'parentsInThread')
def parentsInThread( self, size=0 ):
"""
Return the list of items which are "above" this item in
@@ -178,11 +180,11 @@
self.id = 'talkback'
self._container = PersistentMapping()
- security.declareProtected( CMFCorePermissions.View, 'getId' )
+ security.declareProtected(View, 'getId')
def getId( self ):
return self.id
- security.declareProtected( CMFCorePermissions.View, 'getReply' )
+ security.declareProtected(View, 'getReply')
def getReply( self, reply_id ):
"""
Return a discussion item, given its ID; raise KeyError
@@ -191,7 +193,7 @@
return self._container.get( reply_id ).__of__(self)
# Is this right?
- security.declareProtected( CMFCorePermissions.View, '__bobo_traverse__' )
+ security.declareProtected(View, '__bobo_traverse__')
def __bobo_traverse__(self, REQUEST, name):
"""
This will make this container traversable
@@ -241,8 +243,7 @@
#
# OFS.ObjectManager query interface.
#
- security.declareProtected( CMFCorePermissions.AccessContentsInformation
- , 'objectIds' )
+ security.declareProtected(AccessContentsInformation, 'objectIds')
def objectIds( self, spec=None ):
"""
Return a list of the ids of our DiscussionItems.
@@ -252,8 +253,7 @@
return self._container.keys()
- security.declareProtected( CMFCorePermissions.AccessContentsInformation
- , 'objectItems' )
+ security.declareProtected(AccessContentsInformation, 'objectItems')
def objectItems(self, spec=None):
"""
Return a list of (id, subobject) tuples for our DiscussionItems.
@@ -266,8 +266,7 @@
return r
- security.declareProtected( CMFCorePermissions.AccessContentsInformation
- , 'objectValues' )
+ security.declareProtected(AccessContentsInformation, 'objectValues')
def objectValues(self):
"""
Return a list of our DiscussionItems.
@@ -277,7 +276,7 @@
#
# Discussable interface
#
- security.declareProtected( CMFCorePermissions.ReplyToItem, 'createReply' )
+ security.declareProtected(ReplyToItem, 'createReply')
def createReply( self, title, text, Creator=None ):
"""
Create a reply in the proper place
@@ -303,7 +302,7 @@
return id
- security.declareProtected( CMFCorePermissions.ManagePortal, 'deleteReply' )
+ security.declareProtected(ManagePortal, 'deleteReply')
def deleteReply( self, reply_id ):
""" Remove a reply from this container """
if self._container.has_key( reply_id ):
@@ -322,7 +321,7 @@
del self._container[reply_id]
- security.declareProtected( CMFCorePermissions.View, 'hasReplies' )
+ security.declareProtected(View, 'hasReplies')
def hasReplies( self, content_obj ):
"""
Test to see if there are any dicussion items
@@ -333,7 +332,7 @@
else:
return not not len( content_obj.talkback._getReplyResults() )
- security.declareProtected( CMFCorePermissions.View, 'replyCount' )
+ security.declareProtected(View, 'replyCount')
def replyCount( self, content_obj ):
""" How many replies do i have? """
outer = self._getDiscussable( outer=1 )
@@ -359,7 +358,7 @@
return count
- security.declareProtected( CMFCorePermissions.View, 'getReplies' )
+ security.declareProtected(View, 'getReplies')
def getReplies( self ):
"""
Return a sequence of the DiscussionResponse objects which are
@@ -374,7 +373,7 @@
return objects
- security.declareProtected( CMFCorePermissions.View, 'quotedContents' )
+ security.declareProtected(View, 'quotedContents')
def quotedContents(self):
"""
Return this object's contents in a form suitable for inclusion
=== CMF/CMFDefault/DiscussionTool.py 1.10 => 1.11 ===
from OFS.SimpleItem import SimpleItem
from Products.CMFCore.utils import UniqueObject, getToolByName
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import ManagePortal
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from utils import _dtmldir
from DiscussionItem import DiscussionItemContainer
@@ -57,8 +58,7 @@
#
# ZMI methods
#
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'manage_overview' )
+ security.declareProtected(ManagePortal, 'manage_overview')
manage_overview = DTMLFile( 'explainDiscussionTool', _dtmldir )
#
@@ -79,9 +79,7 @@
the site default override.
"""
mtool = getToolByName( self, 'portal_membership' )
- if not mtool.checkPermission( CMFCorePermissions.ModifyPortalContent
- , content
- ):
+ if not mtool.checkPermission(ModifyPortalContent, content):
raise "Unauthorized"
if allowDiscussion is None or allowDiscussion == 'None':
=== CMF/CMFDefault/Document.py 1.49 => 1.50 ===
from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.PortalContent import NoWL, ResourceLockedError
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore.utils import format_stx, keywordsplitter
from DublinCore import DefaultDublinCoreImpl
@@ -44,20 +45,17 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'document_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'document_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'action' : 'metadata_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
)
}
@@ -113,12 +111,10 @@
self._edit( text=text, text_format=text_format )
self.setFormat( text_format )
- security.declareProtected(CMFCorePermissions.ModifyPortalContent,
- 'manage_edit')
+ security.declareProtected(ModifyPortalContent, 'manage_edit')
manage_edit = DTMLFile('zmi_editDocument', _dtmldir)
- security.declareProtected(CMFCorePermissions.ModifyPortalContent,
- 'manage_editDocument' )
+ security.declareProtected(ModifyPortalContent, 'manage_editDocument')
def manage_editDocument( self, text, text_format, file='', REQUEST=None ):
""" A ZMI (Zope Management Interface) level editing method """
Document.edit( self, text_format=text_format, text=text, file=file )
@@ -153,7 +149,7 @@
self.cooked_text = format_stx(text=text, level=level)
self.text = text
- security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
+ security.declareProtected(ModifyPortalContent, 'edit')
def edit( self
, text_format
, text
@@ -178,7 +174,7 @@
self._edit(text=text, text_format=text_format, safety_belt=safety_belt)
self.reindexObject()
- security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'setMetadata')
+ security.declareProtected(ModifyPortalContent, 'setMetadata')
def setMetadata(self, headers):
headers['Format'] = self.Format()
new_subject = keywordsplitter(headers)
@@ -280,7 +276,7 @@
return 1
### Content accessor methods
- security.declareProtected(CMFCorePermissions.View, 'SearchableText')
+ security.declareProtected(View, 'SearchableText')
def SearchableText(self):
""" Used by the catalog for basic full text indexing """
return "%s %s %s" % ( self.Title()
@@ -288,7 +284,7 @@
, self.EditableBody()
)
- security.declareProtected(CMFCorePermissions.View, 'CookedBody')
+ security.declareProtected(View, 'CookedBody')
def CookedBody(self, stx_level=None, setlevel=0):
"""\
The prepared basic rendering of an object. For Documents, this
@@ -311,7 +307,7 @@
self.cooked_text = cooked
return cooked
- security.declareProtected(CMFCorePermissions.View, 'EditableBody')
+ security.declareProtected(View, 'EditableBody')
def EditableBody(self):
"""\
The editable body of text. This is the raw structured text, or
@@ -319,12 +315,12 @@
"""
return self.text
- security.declareProtected(CMFCorePermissions.View, 'Description')
+ security.declareProtected(View, 'Description')
def Description(self):
""" Dublin core description, also important for indexing """
return self.description
- security.declareProtected(CMFCorePermissions.View, 'Format')
+ security.declareProtected(View, 'Format')
def Format(self):
""" Returns a content-type style format of the underlying source """
if self.text_format == 'html':
@@ -333,8 +329,7 @@
return 'text/plain'
- security.declareProtected(CMFCorePermissions.ModifyPortalContent,
- 'setFormat' )
+ security.declareProtected(ModifyPortalContent, 'setFormat')
def setFormat(self, value):
value = str(value)
if value == 'text/html' or value == 'html':
@@ -346,7 +341,7 @@
setFormat = WorkflowAction(setFormat)
## FTP handlers
- security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'PUT')
+ security.declareProtected(ModifyPortalContent, 'PUT')
def PUT(self, REQUEST, RESPONSE):
""" Handle HTTP (and presumably FTP?) PUT requests """
@@ -390,7 +385,7 @@
'</html>\n'
)
- security.declareProtected( CMFCorePermissions.View, 'manage_FTPget' )
+ security.declareProtected(View, 'manage_FTPget')
def manage_FTPget(self):
"Get the document body for FTP download (also used for the WebDAV SRC)"
join = string.join
@@ -416,7 +411,7 @@
return bodytext
- security.declareProtected( CMFCorePermissions.View, 'get_size' )
+ security.declareProtected(View, 'get_size')
def get_size( self ):
""" Used for FTP and apparently the ZMI now too """
return len(self.manage_FTPget())
=== CMF/CMFDefault/DublinCore.py 1.21 => 1.22 ===
from utils import tuplize, _dtmldir, semi_split
from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
class DefaultDublinCoreImpl( PropertyManager ):
@@ -308,65 +308,56 @@
attrib = DateTime( attrib )
return attrib
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setTitle' )
+ security.declareProtected(ModifyPortalContent, 'setTitle')
def setTitle( self, title ):
"Dublin Core element - resource name"
self.title = title
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setSubject' )
+ security.declareProtected(ModifyPortalContent, 'setSubject')
def setSubject( self, subject ):
"Dublin Core element - resource keywords"
self.subject = tuplize( 'subject', subject )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setDescription' )
+ security.declareProtected(ModifyPortalContent, 'setDescription')
def setDescription( self, description ):
"Dublin Core element - resource summary"
self.description = description
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setContributors' )
+ security.declareProtected(ModifyPortalContent, 'setContributors')
def setContributors( self, contributors ):
"Dublin Core element - additional contributors to resource"
# XXX: fixme
self.contributors = tuplize('contributors', contributors, semi_split)
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setEffectiveDate' )
+ security.declareProtected(ModifyPortalContent, 'setEffectiveDate')
def setEffectiveDate( self, effective_date ):
"""
Dublin Core element - date resource becomes effective.
"""
self.effective_date = self._datify( effective_date )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setExpirationDate' )
+ security.declareProtected(ModifyPortalContent, 'setExpirationDate')
def setExpirationDate( self, expiration_date ):
"""
Dublin Core element - date resource expires.
"""
self.expiration_date = self._datify( expiration_date )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setFormat' )
+ security.declareProtected(ModifyPortalContent, 'setFormat')
def setFormat( self, format ):
"""
Dublin Core element - resource format
"""
self.format = format
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setLanguage' )
+ security.declareProtected(ModifyPortalContent, 'setLanguage')
def setLanguage( self, language ):
"""
Dublin Core element - resource language
"""
self.language = language
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setRights' )
+ security.declareProtected(ModifyPortalContent, 'setRights')
def setRights( self, rights ):
"""
Dublin Core element - resource copyright
@@ -402,12 +393,10 @@
self.setLanguage( language )
self.setRights( rights )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'manage_metadata' )
+ security.declareProtected(ModifyPortalContent, 'manage_metadata')
manage_metadata = DTMLFile( 'zmi_metadata', _dtmldir )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'manage_editMetadata' )
+ security.declareProtected(ModifyPortalContent, 'manage_editMetadata')
def manage_editMetadata( self
, title
, subject
@@ -431,8 +420,7 @@
+ '/manage_metadata'
+ '?manage_tabs_message=Metadata+updated.' )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'editMetadata' )
+ security.declareProtected(ModifyPortalContent, 'editMetadata')
def editMetadata(self
, title=''
, subject=()
=== CMF/CMFDefault/File.py 1.19 => 1.20 ===
import Globals
from DublinCore import DefaultDublinCoreImpl
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.WorkflowCore import WorkflowAction
@@ -41,26 +42,22 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'file_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'download'
, 'name' : 'Download'
, 'action' : ''
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'file_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'action' : 'metadata_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
)
}
@@ -139,8 +136,8 @@
icon = PortalContent.icon
__ac_permissions__ = (
- (CMFCorePermissions.View, ('download',)),
- (CMFCorePermissions.ModifyPortalContent, ('edit',)),
+ (View, ('download',)),
+ (ModifyPortalContent, ('edit',)),
)
def __init__( self
=== CMF/CMFDefault/Image.py 1.17 => 1.18 ===
import Globals
from DublinCore import DefaultDublinCoreImpl
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.WorkflowCore import WorkflowAction
factory_type_information = ( { 'id' : 'Image'
@@ -39,20 +40,17 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'image_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'image_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'action' : 'metadata_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
)
}
@@ -130,7 +128,7 @@
icon = PortalContent.icon
__ac_permissions__ = (
- (CMFCorePermissions.ModifyPortalContent, ('edit',)),
+ (ModifyPortalContent, ('edit',)),
)
def __init__( self
=== CMF/CMFDefault/Link.py 1.23 => 1.24 ===
from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.PortalContent import PortalContent, NoWL
from Products.CMFCore.PortalContent import ResourceLockedError
from Products.CMFCore.WorkflowCore import WorkflowAction
@@ -42,20 +43,17 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'link_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'link_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'action' : 'metadata_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
)
}
@@ -107,12 +105,10 @@
self._edit(remote_url)
self.format=self.URL_FORMAT
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'manage_edit' )
+ security.declareProtected(ModifyPortalContent, 'manage_edit')
manage_edit = DTMLFile( 'zmi_editLink', _dtmldir )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'manage_editLink' )
+ security.declareProtected(ModifyPortalContent, 'manage_editLink')
def manage_editLink( self, remote_url, REQUEST=None ):
"""
Update the Link via the ZMI.
@@ -146,7 +142,7 @@
url = urlparse.urlunparse(tokens)
self.remote_url = url
- security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
+ security.declareProtected(ModifyPortalContent, 'edit')
def edit(self, remote_url ):
""" Update and reindex. """
@@ -155,14 +151,14 @@
edit = WorkflowAction( edit )
- security.declareProtected( CMFCorePermissions.View, 'SearchableText' )
+ security.declareProtected(View, 'SearchableText')
def SearchableText(self):
"""
text for indexing
"""
return "%s %s" % (self.title, self.description)
- security.declareProtected( CMFCorePermissions.View, 'getRemoteUrl' )
+ security.declareProtected(View, 'getRemoteUrl')
def getRemoteUrl(self):
"""
returns the remote URL of the Link
@@ -195,7 +191,7 @@
)
## FTP handlers
- security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'PUT')
+ security.declareProtected(ModifyPortalContent, 'PUT')
def PUT(self, REQUEST, RESPONSE):
"""
Handle HTTP / WebDAV / FTP PUT requests.
@@ -213,7 +209,7 @@
RESPONSE.setStatus(423)
return RESPONSE
- security.declareProtected( CMFCorePermissions.View, 'manage_FTPget' )
+ security.declareProtected(View, 'manage_FTPget')
def manage_FTPget(self):
"""
Get the link as text for WebDAV src / FTP download.
@@ -226,7 +222,7 @@
return bodytext
- security.declareProtected( CMFCorePermissions.View, 'get_size' )
+ security.declareProtected(View, 'get_size')
def get_size( self ):
"""
Used for FTP and apparently the ZMI now too
=== CMF/CMFDefault/MetadataTool.py 1.16 => 1.17 ===
from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo, getSecurityManager
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ManagePortal
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from utils import _dtmldir
@@ -47,7 +49,7 @@
#
# Mutator.
#
- security.declareProtected( CMFCorePermissions.ManagePortal , 'edit' )
+ security.declareProtected(ManagePortal , 'edit')
def edit( self
, is_required
, supply_default
@@ -64,41 +66,41 @@
#
# Query interface
#
- security.declareProtected( CMFCorePermissions.View , 'isMultiValued' )
+ security.declareProtected(View , 'isMultiValued')
def isMultiValued( self ):
"""
Can this element hold multiple values?
"""
return self.is_multi_valued
- security.declareProtected( CMFCorePermissions.View , 'isRequired' )
+ security.declareProtected(View , 'isRequired')
def isRequired( self ):
"""
Must this element be supplied?
"""
return self.is_required
- security.declareProtected( CMFCorePermissions.View , 'supplyDefault' )
+ security.declareProtected(View , 'supplyDefault')
def supplyDefault( self ):
"""
Should the tool supply a default?
"""
return self.supply_default
- security.declareProtected( CMFCorePermissions.View , 'defaultValue' )
+ security.declareProtected(View , 'defaultValue')
def defaultValue( self ):
"""
If so, what is the default?
"""
return self.default_value
- security.declareProtected( CMFCorePermissions.View , 'enforceVocabulary' )
+ security.declareProtected(View , 'enforceVocabulary')
def enforceVocabulary( self ):
"""
"""
return self.enforce_vocabulary
- security.declareProtected( CMFCorePermissions.View , 'allowedVocabulary' )
+ security.declareProtected(View , 'allowedVocabulary')
def allowedVocabulary( self ):
"""
"""
@@ -136,14 +138,14 @@
def _makePolicy( self ):
return MetadataElementPolicy( self.is_multi_valued )
- security.declareProtected( CMFCorePermissions.View , 'isMultiValued' )
+ security.declareProtected(View , 'isMultiValued')
def isMultiValued( self ):
"""
Is this element multi-valued?
"""
return self.is_multi_valued
- security.declareProtected( CMFCorePermissions.View , 'getPolicy' )
+ security.declareProtected(View , 'getPolicy')
def getPolicy( self, typ=None ):
"""
Find the policy this element for objects whose type
@@ -154,7 +156,7 @@
except KeyError:
return self.policies[ None ]
- security.declareProtected( CMFCorePermissions.View , 'listPolicies' )
+ security.declareProtected(View , 'listPolicies')
def listPolicies( self ):
"""
Return a list of all policies for this element.
@@ -164,7 +166,7 @@
res.append((k, v.__of__(self)))
return res
- security.declareProtected( CMFCorePermissions.ManagePortal , 'addPolicy' )
+ security.declareProtected(ManagePortal , 'addPolicy')
def addPolicy( self, typ ):
"""
Add a policy to this element for objects whose type
@@ -178,7 +180,7 @@
self.policies[ typ ] = self._makePolicy()
- security.declareProtected( CMFCorePermissions.ManagePortal, 'removePolicy' )
+ security.declareProtected(ManagePortal, 'removePolicy')
def removePolicy( self, typ ):
"""
Remove the policy from this element for objects whose type
@@ -247,12 +249,10 @@
+ SimpleItem.manage_options
)
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'manage_overview' )
+ security.declareProtected(ManagePortal, 'manage_overview')
manage_overview = DTMLFile( 'explainMetadataTool', _dtmldir )
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'propertiesForm' )
+ security.declareProtected(ManagePortal, 'propertiesForm')
propertiesForm = DTMLFile( 'metadataProperties', _dtmldir )
security.declarePrivate('listActions')
@@ -262,8 +262,7 @@
"""
return self._actions
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'editProperties' )
+ security.declareProtected(ManagePortal, 'editProperties')
def editProperties( self
, publisher=None
# TODO , initial_values_hook=None
@@ -286,12 +285,10 @@
+ '?manage_tabs_message=Tool+updated.'
)
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'elementPoliciesForm' )
+ security.declareProtected(ManagePortal, 'elementPoliciesForm')
elementPoliciesForm = DTMLFile( 'metadataElementPolicies', _dtmldir )
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'addElementPolicy' )
+ security.declareProtected(ManagePortal, 'addElementPolicy')
def addElementPolicy( self
, element
, content_type
@@ -324,8 +321,7 @@
+ '&manage_tabs_message=Policy+added.'
)
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'removeElementPolicy' )
+ security.declareProtected(ManagePortal, 'removeElementPolicy')
def removeElementPolicy( self
, element
, content_type
@@ -346,8 +342,7 @@
+ '&manage_tabs_message=Policy+removed.'
)
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'updateElementPolicy' )
+ security.declareProtected(ManagePortal, 'updateElementPolicy')
def updateElementPolicy( self
, element
, content_type
@@ -383,8 +378,7 @@
#
# Element spec manipulation.
#
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'listElementSpecs' )
+ security.declareProtected(ManagePortal, 'listElementSpecs')
def listElementSpecs( self ):
"""
Return a list of ElementSpecs representing
@@ -395,8 +389,7 @@
res.append((k, v.__of__(self)))
return res
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'getElementSpec' )
+ security.declareProtected(ManagePortal, 'getElementSpec')
def getElementSpec( self, element ):
"""
Return an ElementSpec representing the tool's knowledge
@@ -404,8 +397,7 @@
"""
return self.element_specs[ element ].__of__( self )
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'addElementSpec' )
+ security.declareProtected(ManagePortal, 'addElementSpec')
def addElementSpec( self, element, is_multi_valued, REQUEST=None ):
"""
Add 'element' to our list of managed elements.
@@ -422,8 +414,7 @@
+ '?manage_tabs_message=Element+' + element + '+added.'
)
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'removeElementSpec' )
+ security.declareProtected(ManagePortal, 'removeElementSpec')
def removeElementSpec( self, element, REQUEST=None ):
"""
Remove 'element' from our list of managed elements.
@@ -436,7 +427,7 @@
+ '?manage_tabs_message=Element+' + element + '+removed.'
)
- security.declareProtected( CMFCorePermissions.ManagePortal, 'listPolicies' )
+ security.declareProtected(ManagePortal, 'listPolicies')
def listPolicies( self, typ=None ):
"""
Show all policies for a given content type, or the default
@@ -512,8 +503,7 @@
"""
return self.listAllowedVocabulary( 'Rights', content, content_type )
- security.declareProtected( CMFCorePermissions.ModifyPortalContent
- , 'setInitialMetadata' )
+ security.declareProtected(ModifyPortalContent, 'setInitialMetadata')
def setInitialMetadata( self, content ):
"""
Set initial values for content metatdata, supplying
@@ -533,8 +523,7 @@
# TODO: Call initial_values_hook, if present
- security.declareProtected( CMFCorePermissions.View
- , 'validateMetadata' )
+ security.declareProtected(View, 'validateMetadata')
def validateMetadata( self, content ):
"""
Enforce portal-wide policies about DCI, e.g.,
=== CMF/CMFDefault/NewsItem.py 1.15 => 1.16 ===
from Document import Document
from utils import parseHeadersBody
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ModifyPortalContent
from AccessControl import ClassSecurityInfo
from Products.CMFCore.WorkflowCore import WorkflowAction
@@ -37,20 +38,17 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : 'newsitem_view'
- , 'permissions' : (
- CMFCorePermissions.View, )
+ , 'permissions' : (View,)
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'newsitem_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
, { 'id' : 'metadata'
, 'name' : 'Metadata'
, 'action' : 'metadata_edit_form'
- , 'permissions' : (
- CMFCorePermissions.ModifyPortalContent, )
+ , 'permissions' : (ModifyPortalContent,)
}
)
}
@@ -87,7 +85,7 @@
security = ClassSecurityInfo()
- security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
+ security.declareProtected(ModifyPortalContent, 'edit')
def edit( self, text, description=None, text_format=None ):
"""
Edit the News Item
=== CMF/CMFDefault/PropertiesTool.py 1.7 => 1.8 ===
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import ManagePortal
from utils import _dtmldir
@@ -37,7 +37,7 @@
, description='Reconfigure the portal'
, action=Expression(
text='string: ${portal_url}/reconfig_form')
- , permissions=(CMFCorePermissions.ManagePortal,)
+ , permissions=(ManagePortal,)
, category='global'
, condition=None
, visible=1
@@ -54,8 +54,7 @@
#
# ZMI methods
#
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'manage_overview' )
+ security.declareProtected(ManagePortal, 'manage_overview')
manage_overview = DTMLFile( 'explainPropertiesTool', _dtmldir )
#
@@ -68,8 +67,7 @@
"""
return self._actions
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'editProperties' )
+ security.declareProtected(ManagePortal, 'editProperties')
def editProperties(self, props):
'''Change portal settings'''
aq_parent(aq_inner(self)).manage_changeProperties(props)
=== CMF/CMFDefault/SkinnedFolder.py 1.11 => 1.12 ===
from Products.CMFCore.PortalFolder import PortalFolder
from Products.CMFCore.utils import getToolByName
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ManageProperties
+from Products.CMFCore.CMFCorePermissions import ListFolderContents
from AccessControl import ClassSecurityInfo, Owned
from Globals import InitializeClass
from ComputedAttribute import ComputedAttribute
@@ -37,22 +39,19 @@
( { 'id' : 'view'
, 'name' : 'View'
, 'action' : ''
- , 'permissions' :
- (CMFCorePermissions.View,)
+ , 'permissions' : (View,)
, 'category' : 'folder'
}
, { 'id' : 'edit'
, 'name' : 'Edit'
, 'action' : 'folder_edit_form'
- , 'permissions' :
- (CMFCorePermissions.ManageProperties,)
+ , 'permissions' : (ManageProperties,)
, 'category' : 'folder'
}
, { 'id' : 'foldercontents'
, 'name' : 'Folder contents'
, 'action' : 'folder_contents'
- , 'permissions' :
- (CMFCorePermissions.ListFolderContents,)
+ , 'permissions' : (ListFolderContents,)
, 'category' : 'folder'
}
)
@@ -80,12 +79,12 @@
else:
return view()
- security.declareProtected( CMFCorePermissions.View, 'view' )
+ security.declareProtected(View, 'view')
view = __call__
index_html = None # This special value informs ZPublisher to use __call__
- security.declareProtected( CMFCorePermissions.View, 'Creator' )
+ security.declareProtected(View, 'Creator')
def Creator( self ):
"""
Return the ID of our owner.
=== CMF/CMFDefault/SyndicationTool.py 1.13 => 1.14 ===
security.declareProtected(ManagePortal, 'overview')
overview = HTMLFile('synOverview', _dtmldir)
- security.declareProtected(ManagePortal, \
- 'propertiesForm')
+ security.declareProtected(ManagePortal, 'propertiesForm')
propertiesForm = HTMLFile('synProps', _dtmldir)
security.declareProtected(ManagePortal, 'policiesForm')
=== CMF/CMFDefault/URLTool.py 1.11 => 1.12 ===
from Products.CMFCore.ActionProviderBase import ActionProviderBase
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.Expression import Expression
-from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.CMFCorePermissions import View
+from Products.CMFCore.CMFCorePermissions import ManagePortal
from utils import _dtmldir
class URLTool (UniqueObject, SimpleItem, ActionProviderBase):
@@ -35,7 +36,7 @@
_actions = []
security = ClassSecurityInfo()
- security.declareObjectProtected( CMFCorePermissions.View )
+ security.declareObjectProtected(View)
manage_options = ( ActionProviderBase.manage_options +
({ 'label' : 'Overview', 'action' : 'manage_overview' }
@@ -46,8 +47,7 @@
#
# ZMI methods
#
- security.declareProtected( CMFCorePermissions.ManagePortal
- , 'manage_overview' )
+ security.declareProtected(ManagePortal, 'manage_overview')
manage_overview = DTMLFile( 'explainURLTool', _dtmldir )
#
=== CMF/CMFDefault/utils.py 1.14 => 1.15 ===
security = ModuleSecurityInfo( 'Products.CMFDefault.utils' )
-security.declarePublic( 'formatRFC822Headers'
- , 'parseHeadersBody'
- , 'semi_split'
- , 'comma_split'
- , 'seq_strip'
- , 'tuplize'
- , 'scrubHTML'
- , 'isHTMLSafe'
- , 'bodyfinder'
- , 'html_headcheck'
- )
-
-security.declarePrivate( '_dtmldir'
- , '_bodyre'
- , '_endbodyre'
- , '_htfinder'
- )
-
+security.declarePrivate('_dtmldir')
_dtmldir = os.path.join( package_home( globals() ), 'dtml' )
+security.declarePublic('formatRFC822Headers')
def formatRFC822Headers( headers ):
""" Convert the key-value pairs in 'headers' to valid RFC822-style
@@ -47,6 +31,7 @@
return '\r\n'.join( munged )
+security.declarePublic('parseHeadersBody')
def parseHeadersBody( body, headers=None, rc=re.compile( r'\n|\r\n' ) ):
""" Parse any leading 'RFC-822'-ish headers from an uploaded
@@ -117,19 +102,22 @@
return headers, '\n'.join( lines[ i+1: ] )
+security.declarePublic('semi_split')
def semi_split(s):
""" Split 's' on semicolons.
"""
return map(lambda x: x.strip(), s.split( ';' ) )
+security.declarePublic('comma_split')
def comma_split(s):
""" Split 's' on commas.
"""
return map(lambda x: x.strip(), s.split( ',') )
-def seq_strip (seq, stripper=lambda x: x.strip() ):
+security.declarePublic('seq_strip')
+def seq_strip(seq, stripper=lambda x: x.strip() ):
""" Strip a sequence of strings.
"""
@@ -141,6 +129,7 @@
raise ValueError, "%s of unsupported sequencetype %s" % ( seq, type( seq ) )
+security.declarePublic('tuplize')
def tuplize( valueName, value, splitter=lambda x: x.strip() ):
if type( value ) == type( () ):
@@ -347,6 +336,7 @@
self.result = "%s</%s>" % (self.result, tag)
remTag = '</%s>' % tag
+security.declarePublic('scrubHTML')
def scrubHTML( html ):
""" Strip illegal HTML tags from string text.
@@ -356,6 +346,7 @@
parser.close()
return parser.result
+security.declarePublic('isHTMLSafe')
def isHTMLSafe( html ):
""" Would current HTML be permitted to be saved?
@@ -367,10 +358,13 @@
else:
return 1
+security.declarePrivate('_bodyre')
_bodyre = re.compile( r'^\s*<html.*<body.*?>', re.DOTALL | re.I )
+security.declarePrivate('_endbodyre')
_endbodyre = re.compile( r'</body', re.DOTALL | re.I )
+security.declarePublic('bodyfinder')
def bodyfinder( text ):
bod = _bodyre.search( text )
@@ -383,8 +377,10 @@
else:
return text[bod.end():end.start()]
+security.declarePrivate('_htfinder')
_htfinder = re.compile( r'<html', re.DOTALL | re.I )
+security.declarePublic('html_headcheck')
def html_headcheck( html ):
""" Return 'true' if document looks HTML-ish enough.