[6063] | 1 | ##
|
---|
| 2 | ## restwidget.py
|
---|
| 3 | ##
|
---|
| 4 | ## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
|
---|
| 5 | ## This program is free software; you can redistribute it and/or modify
|
---|
| 6 | ## it under the terms of the GNU General Public License as published by
|
---|
| 7 | ## the Free Software Foundation; either version 2 of the License, or
|
---|
| 8 | ## (at your option) any later version.
|
---|
| 9 | ##
|
---|
| 10 | ## This program is distributed in the hope that it will be useful,
|
---|
| 11 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | ## GNU General Public License for more details.
|
---|
| 14 | ##
|
---|
| 15 | ## You should have received a copy of the GNU General Public License
|
---|
| 16 | ## along with this program; if not, write to the Free Software
|
---|
| 17 | ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 18 | ##
|
---|
| 19 | """A widget that renders restructured text.
|
---|
| 20 | """
|
---|
| 21 | from zope.formlib.textwidgets import TextWidget
|
---|
| 22 | from zope.formlib.widget import renderElement, DisplayWidget
|
---|
| 23 | from waeup.sirp.utils.helpers import ReST2HTML
|
---|
| 24 |
|
---|
| 25 |
|
---|
[6084] | 26 | class ReSTDisplayWidget(DisplayWidget):
|
---|
[6063] | 27 | """Restructured Text widget.
|
---|
| 28 | """
|
---|
| 29 |
|
---|
| 30 | def __call__(self):
|
---|
| 31 | if self._renderedValueSet():
|
---|
| 32 | value = self._data
|
---|
| 33 | else:
|
---|
| 34 | value = self.context.default
|
---|
| 35 | if value == self.context.missing_value:
|
---|
| 36 | return ""
|
---|
| 37 | return renderElement(u'div id="rest"',
|
---|
| 38 | contents=ReST2HTML(value)) |
---|