1 # (c) 2003 Centre de Recherche en Informatique ENSMP Fontainebleau <http://cri.ensmp.fr>
2 # (c) 2003 Benoît PIN <mailto:pin@cri.ensmp.fr>
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License version 2 as published
6 # by the Free Software Foundation.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 from AccessControl
import ClassSecurityInfo
22 from Globals
import InitializeClass
23 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
, AccessContentsInformation
24 from Products
.CMFCore
.PortalContent
import PortalContent
25 from Products
.CMFDefault
.DublinCore
import DefaultDublinCoreImpl
26 from Products
.CMFCore
.utils
import getToolByName
28 from MosaicBlock
import MosaicBlock
30 factory_type_information
= (
31 {'id': 'Mosaic Document',
32 'title': '_mosaic_document_',
33 'content_icon': 'mosaic_icon.png',
34 'product': 'MosaicDocument',
35 'factory': 'addMosaicDocument',
36 'meta_type': 'Mosaic Document',
37 'immediate_view': 'mosaicdocument_edit_form',
38 'allow_discussion': 0,
39 'filter_content_types': 0,
40 'actions': ({'id': 'view',
42 'action': 'mosaicdocument_view',
43 'permissions': (View
,)},
47 'action': 'mosaicdocument_edit_form',
48 'permissions': (ModifyPortalContent
,)},
52 'action': 'metadata_edit_form',
54 'permissions': (ModifyPortalContent
, )},
61 class MosaicDocument(MosaicBlock
, PortalContent
, DefaultDublinCoreImpl
) :
65 meta_type
= 'Mosaic Document'
67 isPrincipiaFolderish
= 0
69 security
= ClassSecurityInfo()
71 def indexObject(self
) :
72 if getattr(self
, 'noIndex', None) : return
73 PortalContent
.indexObject(self
)
75 unindexObject
= PortalContent
.unindexObject
77 def reindexObject(self
, idxs
=[]) :
78 if getattr(self
, 'noIndex', None) : return
79 PortalContent
.reindexObject(self
, idxs
=idxs
)
81 setTitle
= DefaultDublinCoreImpl
.setTitle
82 setDescription
= DefaultDublinCoreImpl
.setDescription
84 Title
= DefaultDublinCoreImpl
.Title
85 Description
= DefaultDublinCoreImpl
.Description
86 Type
= DefaultDublinCoreImpl
.Type
89 def __init__(self
, id, rules
=None, initSubObjects
=None, **kw
) :
90 DefaultDublinCoreImpl
.__init
__(self
, **kw
)
92 self
._blockRules
= rules
93 self
._initSubObjects
(initSubObjects
)
95 def _initSubObjects(self
, subObjects
) :
98 security
.declareProtected(View
, 'SearchableText')
99 def SearchableText(self
) :
101 Sets new permissions/roles after this object changed levels
102 or after one of its levels changed of reviewers/readers.
104 return '%s %s %s' % (self
.title
, self
.description
, MosaicBlock
.SearchableText(self
))
107 InitializeClass(MosaicDocument
)
110 def addMosaicDocument(dispatcher
, id, REQUEST
=None, **kw
) :
111 """Ajoute Mosaic Document"""
112 ob
= MosaicDocument(id, **kw
)
113 dispatcher
.Destination()._setObject
(id, ob
)
115 REQUEST
.RESPONSE
.redirect(dispatcher
.DestinationURL() + 'manage_main')
120 from Products
.CMFCore
.Expression
import Expression
as CMFExpression
122 class Expression(CMFExpression
) :
123 def __call__(self
, econtext
=None) :
124 """ render the result of expression if an expression context is given
128 return CMFExpression
.__call
__(self
, econtext
)
132 def __len__(self
) : return 0