source: main/waeup.sirp/trunk/src/waeup/sirp/widgets/restwidget.py @ 6843

Last change on this file since 6843 was 6084, checked in by Henrik Bettermann, 14 years ago

Rename RestWidget? to RestDisplayWidget?.

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
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"""
21from zope.formlib.textwidgets import TextWidget
22from zope.formlib.widget import renderElement, DisplayWidget
23from waeup.sirp.utils.helpers import ReST2HTML
24
25
26class ReSTDisplayWidget(DisplayWidget):
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))
Note: See TracBrowser for help on using the repository browser.