[CMF-checkins] CVS: CMF/CMFDefault - Link.py:1.13.2.1.2.1
Tres Seaver
tseaver@zope.com
Tue, 8 Jan 2002 08:19:19 -0500
Update of /cvs-repository/CMF/CMFDefault
In directory cvs.zope.org:/tmp/cvs-serv28958
Modified Files:
Tag: tseaver-tracker_364-branch
Link.py
Log Message:
- Add ZMI interface for editing Link URL (Tracker #364).
=== CMF/CMFDefault/Link.py 1.13.2.1 => 1.13.2.1.2.1 ===
#
##############################################################################
+""" Link instances represent explicit links-as-content.
+
+$Id$
"""
-"""
+__version__ = "$Revision$"[11:-2]
-ADD_CONTENT_PERMISSION = 'Add portal content'
+import string
+import urlparse
-import Globals, string, urlparse
-from Globals import InitializeClass
+from Globals import InitializeClass, DTMLFile
from AccessControl import ClassSecurityInfo
-from Products.CMFCore.PortalContent import PortalContent
-from DublinCore import DefaultDublinCoreImpl
from Products.CMFCore import CMFCorePermissions
+from Products.CMFCore.PortalContent import PortalContent
from Products.CMFCore.WorkflowCore import WorkflowAction
from Products.CMFCore.utils import keywordsplitter
-from utils import parseHeadersBody
+
+from DublinCore import DefaultDublinCoreImpl
+from utils import parseHeadersBody, _dtmldir
factory_type_information = ( { 'id' : 'Link'
, 'meta_type' : 'Link'
@@ -66,7 +70,7 @@
, description=''
):
"""
- Add a Link
+ Add a Link instance to 'self'.
"""
o=Link( id, title, remote_url, description )
self._setObject(id,o)
@@ -83,15 +87,10 @@
, DefaultDublinCoreImpl.__implements__
)
- meta_type='Link'
+ meta_type = 'Link'
effective_date = expiration_date = None
_isDiscussable = 1
- __ac_permissions__=(
- (CMFCorePermissions.View, ('', 'view', 'getRemoteUrl')),
- (CMFCorePermissions.ModifyPortalContent, ('edit',)),
- )
-
security = ClassSecurityInfo()
def __init__( self
@@ -106,8 +105,25 @@
self.remote_url=remote_url
self.description=description
- security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'edit')
- def edit( self, remote_url ):
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent
+ , 'manage_edit' )
+ manage_edit = DTMLFile( 'zmi_editLink', _dtmldir )
+
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent
+ , 'manage_editLink' )
+ def manage_editLink( self, remote_url, REQUEST=None ):
+ """
+ Update the Link via the ZMI.
+ """
+ self._edit( remote_url )
+ if REQUEST is not None:
+ REQUEST['RESPONSE'].redirect( self.absolute_url()
+ + '/manage_edit'
+ + '?manage_tabs_message=Link+updated'
+ )
+
+ security.declarePrivate( '_edit' )
+ def _edit( self, remote_url ):
"""
Edit the Link
"""
@@ -119,7 +135,8 @@
if self.remote_url[-1] == '/':
self.remote_url = self.remote_url[:-1]
- edit = WorkflowAction(edit)
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'edit' )
+ edit = WorkflowAction( _edit )
security.declareProtected( CMFCorePermissions.View, 'SearchableText' )
def SearchableText(self):
@@ -135,6 +152,7 @@
"""
return self.remote_url
+ security.declarePrivate( '_writeFromPUT' )
def _writeFromPUT( self, body ):
headers = {}
@@ -162,10 +180,10 @@
)
## FTP handlers
- security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'PUT')
+ security.declareProtected( CMFCorePermissions.ModifyPortalContent, 'PUT')
def PUT(self, REQUEST, RESPONSE):
"""
- Handle HTTP (and presumably FTP?) PUT requests.
+ Handle HTTP / WebDAV / FTP PUT requests.
"""
self.dav__init(REQUEST, RESPONSE)
body = REQUEST.get('BODY', '')
@@ -175,7 +193,9 @@
security.declareProtected( CMFCorePermissions.View, 'manage_FTPget' )
def manage_FTPget(self):
- "Get the link as text for FTP download (also used for the WebDAV SRC)"
+ """
+ Get the link as text for WebDAV src / FTP download.
+ """
join = string.join
lower = string.lower
hdrlist = self.getMetadataHeaders()
@@ -187,7 +207,9 @@
security.declareProtected( CMFCorePermissions.View, 'get_size' )
def get_size( self ):
- """ Used for FTP and apparently the ZMI now too """
+ """
+ Used for FTP and apparently the ZMI now too
+ """
return len(self.manage_FTPget())
InitializeClass( Link )