e9d19ea12adadd459359f51ed0db744db34d5a44
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
19 from Globals
import InitializeClass
, DTMLFile
20 from Products
.CMFCore
.utils
import getToolByName
22 from AccessControl
import ClassSecurityInfo
23 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
24 from Products
.CMFCore
.DynamicType
import DynamicType
25 from Products
.PageTemplates
.Expressions
import getEngine
26 from Products
.PageTemplates
.Expressions
import SecureModuleImporter
28 class BaseSlot(DynamicType
) :
35 security
= ClassSecurityInfo()
37 security
.declarePublic('callAction')
38 def callAction(self
, actionId
, *args
, **kw
) :
39 """call action from action definitions"""
40 typeTool
= getToolByName(self
, 'portal_types')
42 # !!! id et meta_type doivent etre identiques dans la fti.
43 typeInfo
= typeTool
.getTypeInfo(self
)
44 actionInfo
= typeInfo
.getActionInfo('object/%s' % actionId
)
45 zpt
= getattr(self
, actionInfo
['url'])
46 return zpt(object=self
, block
=self
.aq_parent
, *args
, **kw
)
48 security
.declareProtected(ModifyPortalContent
, 'edit')
49 def edit(self
, **kw
) :
51 for fieldName
in self
._editableFields
:
52 if kw
.has_key(fieldName
) :
53 setattr(self
, fieldName
, kw
[fieldName
])
55 security
.declareProtected(View
, 'getBlock')
57 """ Return the block object where the slot is located """
60 security
.declareProtected(View
, 'getExprContext')
61 def getExprContext(self
, REQUEST
=None) :
62 """Return an expression context customized for expressions properties from slot information"""
63 block
= self
.aq_parent
64 while block
.meta_type
!= 'Mosaic Block' :
65 block
= block
.aq_parent
67 'portal' : self
.portal_url
.getPortalObject(),
69 'block' : self
.aq_parent
,
72 'modules' : SecureModuleImporter
,
75 return getEngine().getContext(data
)
77 security
.declareProtected(View
, 'SearchableText')
78 def SearchableText(self
) :
79 """ Return full text for indexation """
81 for fieldName
in self
._indexableFields
:
82 field
= getattr(self
, fieldName
)
84 text
+= ' %s' % field()
90 def _initDefaultValues(self
) :
93 def indexObject(self
): pass
94 def unindexObject(self
): pass
95 def reindexObject(self
, idxs
=[]): pass
96 def reindexObjectSecurity(self
): pass
97 def notifyWorkflowCreated(self
): pass
100 InitializeClass(BaseSlot
)