1 # -*- coding: utf-8 -*-
2 # (c) 2003 Centre de Recherche en Informatique ENSMP Fontainebleau <http://cri.ensmp.fr>
3 # (c) 2003 BenoƮt PIN <mailto:pin@cri.ensmp.fr>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License version 2 as published
7 # by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 from AccessControl
import ClassSecurityInfo
23 from Globals
import InitializeClass
24 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
, AccessContentsInformation
25 from Products
.CMFCore
.PortalContent
import PortalContent
26 from Products
.CMFDefault
.DublinCore
import DefaultDublinCoreImpl
27 from Products
.CMFCore
.utils
import getToolByName
29 from MosaicBlock
import MosaicBlock
31 factory_type_information
= (
32 {'id': 'Mosaic Document',
33 'title': '_mosaic_document_',
34 'content_icon': 'mosaic_icon.png',
35 'product': 'MosaicDocument',
36 'factory': 'addMosaicDocument',
37 'meta_type': 'Mosaic Document',
38 'immediate_view': 'mosaicdocument_edit_form',
39 'allow_discussion': 0,
40 'filter_content_types': 0,
41 'actions': ({'id': 'view',
43 'action': 'mosaicdocument_view',
44 'permissions': (View
,)},
48 'action': 'mosaicdocument_edit_form',
49 'permissions': (ModifyPortalContent
,)},
53 'action': 'metadata_edit_form',
55 'permissions': (ModifyPortalContent
, )},
62 class MosaicDocument(MosaicBlock
, PortalContent
, DefaultDublinCoreImpl
) :
66 meta_type
= 'Mosaic Document'
68 isPrincipiaFolderish
= 0
70 security
= ClassSecurityInfo()
72 def indexObject(self
) :
73 if getattr(self
, 'noIndex', None) : return
74 PortalContent
.indexObject(self
)
76 unindexObject
= PortalContent
.unindexObject
78 def reindexObject(self
, idxs
=[]) :
79 if getattr(self
, 'noIndex', None) : return
80 PortalContent
.reindexObject(self
, idxs
=idxs
)
82 setTitle
= DefaultDublinCoreImpl
.setTitle
83 setDescription
= DefaultDublinCoreImpl
.setDescription
85 Title
= DefaultDublinCoreImpl
.Title
86 Description
= DefaultDublinCoreImpl
.Description
87 Type
= DefaultDublinCoreImpl
.Type
90 def __init__(self
, id, rules
=None, initSubObjects
=None, **kw
) :
91 DefaultDublinCoreImpl
.__init
__(self
, **kw
)
93 self
._blockRules
= rules
94 self
._initSubObjects
(initSubObjects
)
96 def _initSubObjects(self
, subObjects
) :
99 security
.declareProtected(View
, 'SearchableText')
100 def SearchableText(self
) :
102 Sets new permissions/roles after this object changed levels
103 or after one of its levels changed of reviewers/readers.
105 return '%s %s %s' % (self
.title
, self
.description
, MosaicBlock
.SearchableText(self
))
108 InitializeClass(MosaicDocument
)
111 def addMosaicDocument(dispatcher
, id, REQUEST
=None, **kw
) :
112 """Ajoute Mosaic Document"""
113 ob
= MosaicDocument(id, **kw
)
114 dispatcher
.Destination()._setObject
(id, ob
)
116 REQUEST
.RESPONSE
.redirect(dispatcher
.DestinationURL() + 'manage_main')
121 from Products
.CMFCore
.Expression
import Expression
as CMFExpression
123 class Expression(CMFExpression
) :
124 def __call__(self
, econtext
=None) :
125 """ render the result of expression if an expression context is given
129 return CMFExpression
.__call
__(self
, econtext
)
133 def __len__(self
) : return 0