source: main/waeup.sirp/branches/ulif-schoolgrades/src/waeup/sirp/widgets/sequencewidget.py @ 7781

Last change on this file since 7781 was 7766, checked in by uli, 13 years ago

Add a sirp-local sequence widget. This is currently a plain copy from
the original implementation in zope.formlib but we might want to tweak
the associated template for our own layout.

File size: 1.7 KB
RevLine 
[7766]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
26from zope.formlib.widgets import ListSequenceWidget
27from zope.publisher.interfaces.browser import IBrowserRequest
28from zope.schema.interfaces import IField, IList
29
30class SIRPSequenceWidget(ListSequenceWidget):
31    """A sequence widget for lists.
32
33    This is basically a plain copy from zope.formlib. We have,
34    however, the possibility to tweak the attached template.
35    """
36    template = ViewPageTemplateFile('sequencewidget.pt')
37
38
39# Register our sequence widget as default for lists.
40@grok.adapter(IList, IField, IBrowserRequest)
41@grok.implementer(IInputWidget)
42def seq_input_widget(obj, field, req, *args, **kw):
43    return SIRPSequenceWidget(obj, field, req, *args, **kw)
Note: See TracBrowser for help on using the repository browser.