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
20 from Globals
import InitializeClass
, DTMLFile
21 from Products
.CMFCore
.utils
import getToolByName
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
29 class BaseSlot(DynamicType
) :
36 security
= ClassSecurityInfo()
38 security
.declarePublic('callAction')
39 def callAction(self
, actionId
, *args
, **kw
) :
40 """call action from action definitions"""
41 typeTool
= getToolByName(self
, 'portal_types')
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
)
49 security
.declareProtected(ModifyPortalContent
, 'edit')
50 def edit(self
, **kw
) :
52 for fieldName
in self
._editableFields
:
53 if kw
.has_key(fieldName
) :
54 setattr(self
, fieldName
, kw
[fieldName
])
56 security
.declareProtected(View
, 'getBlock')
58 """ Return the block object where the slot is located """
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
68 'portal' : self
.portal_url
.getPortalObject(),
70 'block' : self
.aq_parent
,
73 'modules' : SecureModuleImporter
,
76 return getEngine().getContext(data
)
78 security
.declareProtected(View
, 'SearchableText')
79 def SearchableText(self
) :
80 """ Return full text for indexation """
82 for fieldName
in self
._indexableFields
:
83 field
= getattr(self
, fieldName
)
85 text
+= ' %s' % field()
91 def _initDefaultValues(self
) :
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
101 InitializeClass(BaseSlot
)