e8daf01f580534e1bb93f4654fbbff5393516c2f
[MosaicDocument.git] / SpacerSlot.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
21 from Globals import InitializeClass
22 from Products.CMFCore.permissions import View, ModifyPortalContent
23 from BaseSlot import BaseSlot
24 from OFS.SimpleItem import SimpleItem
25
26 factory_type_information = ( {'id' : 'Spacer Slot',
27 'meta_type' : 'Spacer Slot',
28 'description' : "Spacer Slot for Mosaic Document",
29 'icon' : 'mosaic_tool/spacer_icon.gif',
30 'product' : 'MosaicDocument',
31 'factory' : 'addSpacerSlot',
32 'immediate_view' : 'view',
33 'actions' :
34 ({'id' : 'view',
35 'name' : 'View',
36 'action' : 'slot_spacer_view',
37 'permissions' : (View, )
38 },
39
40 {'id' : 'edit',
41 'name' : 'Edit',
42 'action' : 'slot_spacer_form',
43 'permissions' : (ModifyPortalContent, )
44 },
45 )
46 },
47 )
48
49
50 class SpacerSlot(BaseSlot, SimpleItem) :
51 """Spacer Slot"""
52 meta_type = 'Spacer Slot'
53
54 _editableFields = ('nbOfSpaces',)
55 _indexableFields = ()
56
57 def __init__(self, id, nbOfSpaces = 3) :
58 self.id = id
59 self.nbOfSpaces = nbOfSpaces
60
61 InitializeClass(SpacerSlot)
62
63 def addSpacerSlot(dispatcher, id, nbOfSpaces = 3) :
64 """Add a new SpacerSlot object"""
65
66 o = SpacerSlot(id, nbOfSpaces)
67 dispatcher.Destination()._setObject(id, o)