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 | |
---|
20 | We provide a sequence widget that better suits our needs layout-wise |
---|
21 | than the default implementation from zope.formlib. |
---|
22 | """ |
---|
23 | import grok |
---|
24 | from zope.browserpage import ViewPageTemplateFile |
---|
25 | from zope.formlib.interfaces import IInputWidget |
---|
26 | from zope.formlib.widgets import ListSequenceWidget |
---|
27 | from zope.publisher.interfaces.browser import IBrowserRequest |
---|
28 | from zope.schema.interfaces import IField, IList |
---|
29 | |
---|
30 | class 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) |
---|
42 | def seq_input_widget(obj, field, req, *args, **kw): |
---|
43 | return SIRPSequenceWidget(obj, field, req, *args, **kw) |
---|