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