vendor/CMF/1.6.3/CMFCore

view PortalContent.py @ 0:587011552858

import CMF 1.6.3
author bdelbosc
date Mon, 23 Apr 2007 13:58:01 +0000
parents
children
line source
1 ##############################################################################
2 #
3 # Copyright (c) 2001 Zope Corporation and Contributors. All Rights Reserved.
4 #
5 # This software is subject to the provisions of the Zope Public License,
6 # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10 # FOR A PARTICULAR PURPOSE.
11 #
12 ##############################################################################
13 """ PortalContent: Base class for all CMF content.
15 $Id$
16 """
18 from Globals import InitializeClass
19 from Acquisition import aq_base
20 from OFS.SimpleItem import SimpleItem
21 from AccessControl import ClassSecurityInfo
22 from webdav.WriteLockInterface import WriteLockInterface
24 from interfaces.Contentish import Contentish
25 from DynamicType import DynamicType
26 from utils import _getViewFor
27 from CMFCatalogAware import CMFCatalogAware
28 from exceptions import ResourceLockedError
29 from permissions import FTPAccess
30 from permissions import View
33 # Old names that some third-party packages may need.
34 NoWL = 0
37 class PortalContent(DynamicType, CMFCatalogAware, SimpleItem):
38 """
39 Base class for portal objects.
41 Provides hooks for reviewing, indexing, and CMF UI.
43 Derived classes must implement the interface described in
44 interfaces/DublinCore.py.
45 """
47 __implements__ = (Contentish,
48 WriteLockInterface,
49 DynamicType.__implements__)
51 isPortalContent = 1
52 _isPortalContent = 1 # More reliable than 'isPortalContent'.
54 manage_options = ( ( { 'label' : 'Dublin Core'
55 , 'action' : 'manage_metadata'
56 }
57 , { 'label' : 'Edit'
58 , 'action' : 'manage_edit'
59 }
60 , { 'label' : 'View'
61 , 'action' : 'view'
62 }
63 )
64 + CMFCatalogAware.manage_options
65 + SimpleItem.manage_options
66 )
68 security = ClassSecurityInfo()
70 security.declareObjectProtected(View)
72 # The security for FTP methods aren't set up by default in our
73 # superclasses... :(
74 security.declareProtected(FTPAccess, 'manage_FTPstat')
75 security.declareProtected(FTPAccess, 'manage_FTPlist')
77 def failIfLocked(self):
78 """ Check if isLocked via webDav
79 """
80 if self.wl_isLocked():
81 raise ResourceLockedError('This resource is locked via webDAV.')
82 return 0
84 #
85 # Contentish interface methods
86 #
87 security.declareProtected(View, 'SearchableText')
88 def SearchableText(self):
89 """ Returns a concatination of all searchable text.
91 Should be overriden by portal objects.
92 """
93 return "%s %s" % (self.Title(), self.Description())
95 def __call__(self):
96 """ Invokes the default view.
97 """
98 ti = self.getTypeInfo()
99 method_id = ti and ti.queryMethodID('(Default)', context=self)
100 if method_id and method_id!='(Default)':
101 method = getattr(self, method_id)
102 else:
103 method = _getViewFor(self)
105 if getattr(aq_base(method), 'isDocTemp', 0):
106 return method(self, self.REQUEST, self.REQUEST['RESPONSE'])
107 else:
108 return method()
110 index_html = None # This special value informs ZPublisher to use __call__
112 security.declareProtected(View, 'view')
113 def view(self):
114 """ Returns the default view even if index_html is overridden.
115 """
116 return self()
118 InitializeClass(PortalContent)