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 OFS
.SimpleItem
import SimpleItem
21 from OFS
.PropertyManager
import PropertyManager
22 from OFS
.Image
import cookId
23 from Globals
import InitializeClass
24 from Products
.CMFCore
.utils
import getToolByName
26 from Products
.CMFCore
.permissions
import View
, ModifyPortalContent
27 from AccessControl
import ClassSecurityInfo
28 from Products
.Plinn
.File
import File
29 from BaseSlot
import BaseSlot
31 factory_type_information
= ( {'id' : 'File Slot',
32 'meta_type' : 'File Slot',
33 'description' : "File Slot for Mosaic Document",
34 'icon' : 'mosaic_tool/bin_icon.gif',
35 'product' : 'MosaicDocument',
36 'factory' : 'addFileSlot',
37 'immediate_view' : 'view',
41 'action' : 'slot_file_view',
42 'permissions' : (View
, )
47 'action' : 'slot_file_form',
48 'permissions' : (ModifyPortalContent
, )
54 class FileSlot(BaseSlot
, File
) :
56 meta_type
= 'File Slot'
59 _indexableFields
= ('title',)
61 security
= ClassSecurityInfo()
63 security
.declareProtected(ModifyPortalContent
, 'edit')
64 def edit(self
, title
='', file='') :
65 """ Edit file slot """
68 self
._edit
(file = file)
69 self
.filename
= cookId(None, None, file)[1]
72 security
.declareProtected(View
, 'SearchableText')
73 def SearchableText(self
) :
74 """ Return full text for indexation """
75 return BaseSlot
.SearchableText(self
) + File
.SearchableText(self
)
78 InitializeClass(FileSlot
)
80 def addFileSlot(dispatcher
, id, title
='', file=''):
82 Add a new FileSlot object.
84 o
= FileSlot(id, title
=title
, file=file)
85 dispatcher
.Destination()._setObject
(id, o
)