############################################################################## # # Copyright (c) 2005 CMFonFive Contributors. All rights reserved. # # This software is distributed under the terms of the Zope Public # License (ZPL) v2.1. See COPYING.txt for more information. # ########################################################################### """ Browser view classes for CMF content. $Id$ """ from Acquisition import Acquired from ZODB.POSException import ConflictError from Products.CMFCore.CMFCorePermissions import ListFolderContents from Products.CMFCore.CMFCorePermissions import ModifyPortalContent from Products.CMFCore.CMFCorePermissions import View from Products.CMFDefault.utils import scrubHTML from Products.Five import BrowserView from Products.PageTemplates.PageTemplateFile import PageTemplateFile class PortalFolderView(BrowserView): getPhysicalPath = Acquired view = PageTemplateFile('www/folder_contents.pt', globals()) class DocumentView(BrowserView): getPhysicalPath = Acquired view = PageTemplateFile('www/document_view.pt', globals()) edit_form = PageTemplateFile('www/document_edit.pt', globals()) def edit(self, text_format, text, file='', SafetyBelt='', change_and_view=''): """Edit a document. """ absolute_url = self.context.absolute_url type_info = self.context.getTypeInfo() action_id = 'edit' msg = 'Document+changed.' try: text = scrubHTML(text) # Strip Javascript, etc. self.context.edit(text_format, text, file, safety_belt=SafetyBelt) except ConflictError: raise except Exception, e: msg = e else: if change_and_view: action_id = view target_action = type_info.getActionById(action_id) self.request.RESPONSE.redirect('%s/%s?portal_status_message=%s' % (absolute_url, target_action, qst))