[CMF-checkins] CVS: CMF/CMFDefault - Document.py:1.47.6.3 File.py:1.18.32.2 Image.py:1.16.32.2 Link.py:1.20.4.4 NewsItem.py:1.15.6.1 __init__.py:1.12.32.2
Florent Guillaume
fg@nuxeo.com
Sun, 4 Aug 2002 00:04:45 -0400
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv3327/CMFDefault
Modified Files:
Tag: CMF-1_3-branch
Document.py File.py Image.py Link.py NewsItem.py __init__.py
Log Message:
Merged change from HEAD:
Code cleanup:
Use declarative security instead of __ac_permissions__.
Use InitializeClass instead of default__class_init__.
Use AddPortalContent instead of ADD_CONTENT_PERMISSION.
Use AddPortalFolders instead of ADD_FOLDERS_PERMISSION.
=== CMF/CMFDefault/Document.py 1.47.6.2 => 1.47.6.3 ===
$Id$
"""
-ADD_CONTENT_PERMISSION = 'Add portal content'
-
import Globals, StructuredText, string, utils, re
from StructuredText.HTMLWithImages import HTMLWithImages
from Globals import DTMLFile, InitializeClass
@@ -102,7 +100,6 @@
_last_safety_belt = ''
_safety_belt = ''
- # Declarative security (replaces __ac_permissions__)
security = ClassSecurityInfo()
def __init__(self, id, title='', description='', text_format='', text=''):
=== CMF/CMFDefault/File.py 1.18.32.1 => 1.18.32.2 ===
make it more Portal-friendly.
"""
-ADD_CONTENT_PERMISSION = 'Add portal content'
+from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
-
-from Globals import HTMLFile, HTML
from Products.CMFCore.PortalContent import PortalContent
-import Globals
from DublinCore import DefaultDublinCoreImpl
from Products.CMFCore import CMFCorePermissions
@@ -138,11 +136,8 @@
_isDiscussable = 1
icon = PortalContent.icon
- __ac_permissions__ = (
- (CMFCorePermissions.View, ('download',)),
- (CMFCorePermissions.ModifyPortalContent, ('edit',)),
- )
-
+ security = ClassSecurityInfo()
+
def __init__( self
, id
, title=''
@@ -163,7 +158,8 @@
DefaultDublinCoreImpl.__init__( self, title, subject, description
, contributors, effective_date, expiration_date
, format, language, rights )
-
+
+ security.declareProtected(CMFCorePermissions.View, 'SearchableText')
def SearchableText(self):
"""
SeachableText is used for full text seraches of a portal. It
@@ -171,16 +167,19 @@
"""
return "%s %s" % (self.title, self.description)
+ security.declarePrivate('manage_beforeDelete')
def manage_afterAdd(self, item, container):
"""Both of my parents have an afterAdd method"""
OFS.Image.File.manage_afterAdd(self, item, container)
PortalContent.manage_afterAdd(self, item, container)
+ security.declarePrivate('manage_beforeDelete')
def manage_beforeDelete(self, item, container):
"""Both of my parents have a beforeDelete method"""
PortalContent.manage_beforeDelete(self, item, container)
OFS.Image.File.manage_beforeDelete(self, item, container)
+ security.declarePrivate('_isNotEmpty')
def _isNotEmpty(self, file):
""" Do various checks on 'file' to try to determine non emptiness. """
if not file:
@@ -198,6 +197,7 @@
if t: return 1
else: return 0
+ security.declarePrivate('_edit')
def _edit(self, precondition='', file=''):
""" Perform changes for user """
if precondition: self.precondition = precondition
@@ -208,6 +208,7 @@
self.setFormat(self.content_type)
+ security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'edit')
def edit(self, precondition='', file=''):
""" Update and reindex. """
self._edit( precondition, file )
@@ -215,6 +216,7 @@
edit = WorkflowAction(edit)
+ security.declareProtected(CMFCorePermissions.View, 'download')
def download(self, REQUEST, RESPONSE):
"""Download this item.
@@ -232,5 +234,6 @@
'attachment; filename=%s' % self.getId())
return OFS.Image.File.index_html(self, REQUEST, RESPONSE)
-Globals.default__class_init__(File)
+
+InitializeClass(File)
=== CMF/CMFDefault/Image.py 1.16.32.1 => 1.16.32.2 ===
Zope's built-in Image object.
"""
-ADD_CONTENT_PERMISSION = 'Add portal content'
+from Globals import InitializeClass
+from AccessControl import ClassSecurityInfo
-
-from Globals import HTMLFile, HTML
from Products.CMFCore.PortalContent import PortalContent
-import Globals
from DublinCore import DefaultDublinCoreImpl
from Products.CMFCore import CMFCorePermissions
@@ -129,10 +127,8 @@
_isDiscussable = 1
icon = PortalContent.icon
- __ac_permissions__ = (
- (CMFCorePermissions.ModifyPortalContent, ('edit',)),
- )
-
+ security = ClassSecurityInfo()
+
def __init__( self
, id
, title=''
@@ -153,7 +149,8 @@
DefaultDublinCoreImpl.__init__( self, title, subject, description
, contributors, effective_date, expiration_date
, format, language, rights )
-
+
+ security.declareProtected(CMFCorePermissions.View, 'SearchableText')
def SearchableText(self):
"""
SeachableText is used for full text seraches of a portal.
@@ -161,16 +158,19 @@
"""
return "%s %s" % (self.title, self.description)
+ security.declarePrivate('manage_beforeDelete')
def manage_afterAdd(self, item, container):
"""Both of my parents have an afterAdd method"""
OFS.Image.Image.manage_afterAdd(self, item, container)
PortalContent.manage_afterAdd(self, item, container)
+ security.declarePrivate('manage_beforeDelete')
def manage_beforeDelete(self, item, container):
"""Both of my parents have a beforeDelete method"""
PortalContent.manage_beforeDelete(self, item, container)
OFS.Image.Image.manage_beforeDelete(self, item, container)
-
+
+ security.declarePrivate('_isNotEmpty')
def _isNotEmpty(self, file):
""" Do various checks on 'file' to try to determine non emptiness. """
if not file:
@@ -188,6 +188,7 @@
if t: return 1
else: return 0
+ security.declarePrivate('_edit')
def _edit(self, precondition='', file=''):
""" Update image. """
if precondition: self.precondition = precondition
@@ -198,6 +199,7 @@
self.setFormat(self.content_type)
+ security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'edit')
def edit(self, precondition='', file=''):
""" Update and reindex. """
self._edit( precondition, file )
@@ -205,6 +207,7 @@
edit = WorkflowAction(edit)
+ security.declareProtected(CMFCorePermissions.View, 'index_html')
def index_html(self, REQUEST, RESPONSE):
"""
Display the image, with or without standard_html_[header|footer],
@@ -214,6 +217,6 @@
# return self.view(self, REQUEST)
return OFS.Image.Image.index_html(self, REQUEST, RESPONSE)
-Globals.default__class_init__(Image)
+InitializeClass(Image)
=== CMF/CMFDefault/Link.py 1.20.4.3 => 1.20.4.4 ===
self.remote_url = url
security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
-
def edit(self, remote_url ):
""" Update and reindex. """
self._edit( remote_url )
=== CMF/CMFDefault/NewsItem.py 1.15 => 1.15.6.1 ===
"""
"""
-ADD_CONTENT_PERMISSION = 'Add portal content'
-
-
-import Globals
-from Globals import HTMLFile, HTML
+from Globals import InitializeClass
from Document import Document
from utils import parseHeadersBody
@@ -99,5 +95,5 @@
Document.edit( self, text_format, text )
-Globals.InitializeClass( NewsItem )
+InitializeClass( NewsItem )
=== CMF/CMFDefault/__init__.py 1.12.32.1 => 1.12.32.2 ===
"""
"""
-ADD_CONTENT_PERMISSION = 'Add portal content'
-
from AccessControl import ModuleSecurityInfo
prod_security = ModuleSecurityInfo( 'Products' )
@@ -31,10 +29,14 @@
import RegistrationTool, URLTool, DublinCore, DiscussionTool
import SyndicationTool
from Products.CMFCore import utils
+from Products.CMFCore.CMFCorePermissions import AddPortalContent
import Products.CMFCore
from Products.CMFCore.DirectoryView import registerDirectory
import DefaultWorkflow
+# Old name that some third-party packages may need.
+ADD_CONTENT_PERMISSION = AddPortalContent
+
#!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
# N.B.: The following symbol controls whether we "inject" the
@@ -121,7 +123,7 @@
utils.ContentInit( 'CMFDefault Content'
, content_types=contentClasses
- , permission=ADD_CONTENT_PERMISSION
+ , permission=AddPortalContent
, extra_constructors=contentConstructors
, fti=Portal.factory_type_information
).initialize( context )