Utilisation des png24 (et apng) pour l'affichage des boutons de déploiement de l...
[MosaicDocument.git] / BaseSlot.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 from Globals import InitializeClass, DTMLFile
21 from Products.CMFCore.utils import getToolByName
22
23 from AccessControl import ClassSecurityInfo
24 from Products.CMFCore.permissions import View, ModifyPortalContent
25 from Products.CMFCore.DynamicType import DynamicType
26 from Products.PageTemplates.Expressions import getEngine
27 from Products.PageTemplates.Expressions import SecureModuleImporter
28
29 class BaseSlot(DynamicType) :
30 """Slot"""
31
32 _isMosaicSlot = 1
33 _editableFields = []
34 _indexableFields = []
35
36 security = ClassSecurityInfo()
37
38 security.declarePublic('callAction')
39 def callAction(self, actionId, *args, **kw) :
40 """call action from action definitions"""
41 typeTool = getToolByName(self, 'portal_types')
42
43 # !!! id et meta_type doivent etre identiques dans la fti.
44 typeInfo = typeTool.getTypeInfo(self)
45 actionInfo = typeInfo.getActionInfo('object/%s' % actionId)
46 zpt = getattr(self, actionInfo['url'])
47 return zpt(object=self, block=self.aq_parent, *args, **kw)
48
49 security.declareProtected(ModifyPortalContent, 'edit')
50 def edit(self, **kw) :
51 """ Edit Slot"""
52 for fieldName in self._editableFields :
53 if kw.has_key(fieldName) :
54 setattr(self, fieldName, kw[fieldName])
55
56 security.declareProtected(View, 'getBlock')
57 def getBlock(self) :
58 """ Return the block object where the slot is located """
59 return self.aq_parent
60
61 security.declareProtected(View, 'getExprContext')
62 def getExprContext(self, REQUEST=None) :
63 """Return an expression context customized for expressions properties from slot information"""
64 block = self.aq_parent
65 while block.meta_type != 'Mosaic Block' :
66 block = block.aq_parent
67 data = {
68 'portal' : self.portal_url.getPortalObject(),
69 'slot' : self,
70 'block' : self.aq_parent,
71 'here' : None,
72 'request' : REQUEST,
73 'modules' : SecureModuleImporter,
74 'nothing' : None,
75 }
76 return getEngine().getContext(data)
77
78 security.declareProtected(View, 'SearchableText')
79 def SearchableText(self) :
80 """ Return full text for indexation """
81 text = ''
82 for fieldName in self._indexableFields :
83 field = getattr(self, fieldName)
84 if callable(field) :
85 text += ' %s' % field()
86 else :
87 text += ' %s' % field
88
89 return text
90
91 def _initDefaultValues(self) :
92 pass
93
94 def indexObject(self): pass
95 def unindexObject(self): pass
96 def reindexObject(self, idxs=[]): pass
97 def reindexObjectSecurity(self): pass
98 def notifyWorkflowCreated(self): pass
99
100
101 InitializeClass(BaseSlot)