source: main/waeup.kofa/trunk/src/waeup/kofa/widgets/sequencewidget.py @ 7915

Last change on this file since 7915 was 7819, checked in by Henrik Bettermann, 13 years ago

KOFA -> Kofa

File size: 2.2 KB
Line 
1## $Id$
2##
3## Copyright (C) 2012 Uli Fouquet & Henrik Bettermann
4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
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 02111-1307 USA
17##
18"""An improved sequence widget.
19
20We provide a sequence widget that better suits our needs layout-wise
21than the default implementation from zope.formlib.
22"""
23import grok
24from zope.browserpage import ViewPageTemplateFile
25from zope.formlib.interfaces import IInputWidget, IDisplayWidget
26from zope.formlib.widgets import (
27    ListSequenceWidget, SequenceDisplayWidget)
28from zope.publisher.interfaces.browser import IBrowserRequest
29from zope.schema.interfaces import IField, IList
30
31class KofaSequenceWidget(ListSequenceWidget):
32    """A sequence widget for lists.
33
34    This is basically a plain copy from zope.formlib. We have,
35    however, the possibility to tweak the attached template.
36    """
37    template = ViewPageTemplateFile('sequencewidget.pt')
38
39class KofaSequenceDisplayWidget(SequenceDisplayWidget):
40    """A sequence widget for lists.
41
42    This is basically a plain copy from zope.formlib. We have,
43    however, the possibility to tweak html tags.
44    """
45
46    tag = None
47    itemTag = 'div'
48
49# Register our sequence widgets as default for lists.
50@grok.adapter(IList, IField, IBrowserRequest)
51@grok.implementer(IInputWidget)
52def seq_input_widget(obj, field, req, *args, **kw):
53    return KofaSequenceWidget(obj, field, req, *args, **kw)
54
55@grok.adapter(IList, IField, IBrowserRequest)
56@grok.implementer(IDisplayWidget)
57def seq_display_widget(obj, field, req, *args, **kw):
58    return KofaSequenceDisplayWidget(obj, field, req, *args, **kw)
Note: See TracBrowser for help on using the repository browser.