Conservation de l'état de déroulement de l'arborescence (seulement pour le déroulement).
[MosaicDocument.git] / MosaicDocument.py
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>
4 #
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.
8 #
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.
13 #
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
17 # 02111-1307, USA.
18 #
19
20
21
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
28
29 from MosaicBlock import MosaicBlock
30
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',
42 'name': 'View',
43 'action': 'mosaicdocument_view',
44 'permissions': (View,)},
45
46 {'id': 'edit',
47 'name': 'Edit',
48 'action': 'mosaicdocument_edit_form',
49 'permissions': (ModifyPortalContent,)},
50
51 {'id': 'metadata',
52 'name': 'Metadata',
53 'action': 'metadata_edit_form',
54 'visible': 0,
55 'permissions': (ModifyPortalContent, )},
56
57 ),
58 },
59 )
60
61
62 class MosaicDocument(MosaicBlock, PortalContent, DefaultDublinCoreImpl) :
63 """
64 Mosaic Document
65 """
66 meta_type = 'Mosaic Document'
67 _isRootBlock = 1
68 isPrincipiaFolderish = 0
69
70 security = ClassSecurityInfo()
71
72 def indexObject(self) :
73 if getattr(self, 'noIndex', None) : return
74 PortalContent.indexObject(self)
75
76 unindexObject = PortalContent.unindexObject
77
78 def reindexObject(self, idxs=[]) :
79 if getattr(self, 'noIndex', None) : return
80 PortalContent.reindexObject(self, idxs=idxs)
81
82 setTitle = DefaultDublinCoreImpl.setTitle
83 setDescription = DefaultDublinCoreImpl.setDescription
84
85 Title = DefaultDublinCoreImpl.Title
86 Description = DefaultDublinCoreImpl.Description
87 Type = DefaultDublinCoreImpl.Type
88
89
90 def __init__(self, id, rules=None, initSubObjects=None, **kw) :
91 DefaultDublinCoreImpl.__init__(self, **kw)
92 self.id = id
93 self._blockRules = rules
94 self._initSubObjects(initSubObjects)
95
96 def _initSubObjects(self, subObjects) :
97 pass
98
99 security.declareProtected(View, 'SearchableText')
100 def SearchableText(self) :
101 """
102 Sets new permissions/roles after this object changed levels
103 or after one of its levels changed of reviewers/readers.
104 """
105 return '%s %s %s' % (self.title, self.description, MosaicBlock.SearchableText(self))
106
107
108 InitializeClass(MosaicDocument)
109
110 # factory
111 def addMosaicDocument(dispatcher, id, REQUEST=None, **kw) :
112 """Ajoute Mosaic Document"""
113 ob = MosaicDocument(id, **kw)
114 dispatcher.Destination()._setObject(id, ob)
115 if REQUEST :
116 REQUEST.RESPONSE.redirect(dispatcher.DestinationURL() + 'manage_main')
117
118
119
120
121 from Products.CMFCore.Expression import Expression as CMFExpression
122
123 class Expression(CMFExpression) :
124 def __call__(self, econtext=None) :
125 """ render the result of expression if an expression context is given
126 else the source text
127 """
128 if econtext :
129 return CMFExpression.__call__(self, econtext)
130 else :
131 return self.text
132
133 def __len__(self) : return 0