Retrait ligne en commentaire.
[MosaicDocument.git] / FileSlot.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 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
25
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
30
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',
38 'actions' :
39 ({'id' : 'view',
40 'name' : 'View',
41 'action' : 'slot_file_view',
42 'permissions' : (View, )
43 },
44
45 {'id' : 'edit',
46 'name' : 'Edit',
47 'action' : 'slot_file_form',
48 'permissions' : (ModifyPortalContent, )
49 },
50 )
51 },
52 )
53
54 class FileSlot(BaseSlot, File) :
55 """File Slot"""
56 meta_type = 'File Slot'
57
58 filename = ''
59 _indexableFields = ('title',)
60
61 security = ClassSecurityInfo()
62
63 security.declareProtected(ModifyPortalContent, 'edit')
64 def edit(self, title='', file='') :
65 """ Edit file slot """
66 self.title = title
67 if file :
68 self._edit(file = file)
69 self.filename = cookId(None, None, file)[1]
70
71
72 security.declareProtected(View, 'SearchableText')
73 def SearchableText(self) :
74 """ Return full text for indexation """
75 return BaseSlot.SearchableText(self) + File.SearchableText(self)
76
77
78 InitializeClass(FileSlot)
79
80 def addFileSlot(dispatcher, id, title='', file=''):
81 """
82 Add a new FileSlot object.
83 """
84 o = FileSlot(id, title=title, file=file)
85 dispatcher.Destination()._setObject(id, o)