4b7c42eeb373e79bc048663e04d0421839d83990
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 OFS
.SimpleItem
import SimpleItem
20 from OFS
.PropertyManager
import PropertyManager
21 from OFS
.Image
import cookId
22 from Globals
import InitializeClass
23 from Products
.CMFCore
.utils
import getToolByName
25 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
26 from AccessControl
import ClassSecurityInfo
27 from Products
.Plinn
.File
import File
28 from BaseSlot
import BaseSlot
30 factory_type_information
= ( {'id' : 'File Slot',
31 'meta_type' : 'File Slot',
32 'description' : "File Slot for Mosaic Document",
33 'icon' : 'mosaic_tool/bin_icon.gif',
34 'product' : 'MosaicDocument',
35 'factory' : 'addFileSlot',
36 'immediate_view' : 'view',
40 'action' : 'slot_file_view',
41 'permissions' : (View
, )
46 'action' : 'slot_file_form',
47 'permissions' : (ModifyPortalContent
, )
53 class FileSlot(BaseSlot
, File
) :
55 meta_type
= 'File Slot'
58 _indexableFields
= ('title',)
60 security
= ClassSecurityInfo()
62 security
.declareProtected(ModifyPortalContent
, 'edit')
63 def edit(self
, title
='', file='') :
64 """ Edit file slot """
67 self
._edit
(file = file)
68 self
.filename
= cookId(None, None, file)[1]
71 security
.declareProtected(View
, 'SearchableText')
72 def SearchableText(self
) :
73 """ Return full text for indexation """
74 return BaseSlot
.SearchableText(self
) + File
.SearchableText(self
)
77 InitializeClass(FileSlot
)
79 def addFileSlot(dispatcher
, id, title
='', file=''):
81 Add a new FileSlot object.
83 o
= FileSlot(id, title
=title
, file=file)
84 dispatcher
.Destination()._setObject
(id, o
)