[Mpuls-commits] r4602 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 10 13:35:19 CET 2011


Author: bh
Date: 2011-02-10 13:35:18 +0100 (Thu, 10 Feb 2011)
New Revision: 4602

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/helpers.py
Log:
* mpulsweb/lib/helpers.py (tag): Removed. It's now implemented in
formed. Adapt imports accordingly. There's still code that imports
tag from mpulsweb.lib.helpers, though.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-02-10 08:55:48 UTC (rev 4601)
+++ base/trunk/ChangeLog	2011-02-10 12:35:18 UTC (rev 4602)
@@ -1,3 +1,9 @@
+2011-02-10  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/helpers.py (tag): Removed. It's now implemented in
+	formed. Adapt imports accordingly. There's still code that imports
+	tag from mpulsweb.lib.helpers, though.
+
 2011-02-09  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/controllers/formularpage.py

Modified: base/trunk/mpulsweb/lib/helpers.py
===================================================================
--- base/trunk/mpulsweb/lib/helpers.py	2011-02-10 08:55:48 UTC (rev 4601)
+++ base/trunk/mpulsweb/lib/helpers.py	2011-02-10 12:35:18 UTC (rev 4602)
@@ -47,7 +47,8 @@
 from webhelpers.html import escape, HTML, literal, url_escape
 from webhelpers.html.tags import *
 
-from formed.meta.data import PageNode 
+from formed.meta.data import PageNode
+from formed.renderer.helpers import tag
 
 from mpulsweb.lib.security import hasRole, getKAName
 
@@ -73,66 +74,7 @@
         return s
     return unicode(str(s), 'utf-8')
 
-# html helper
-def tag(tagname, _close=False,
-        _booleans=('checked', 'disabled', 'multiple', 'selected'), **attrs):
-    """Create an opening HTML tag with properly escaped attributes.
 
-    The tagname parameter gives the name of the tag.  The attributes and
-    their values are given as keyword parameters.  Most attributes have
-    string values.  Boolean attributes are treated as described below.
-    The values of string attributes are converted to strings if they are
-    not aleady strings (byte-strings or unicode) using these rules: None
-    is converted to the empty string, other values are converted using
-    the str function.  After conversion the values of string attributes
-    will be properly escaped as attribute values when inserted into the
-    tag.
-
-    Boolean flags are treated differently: if the value of such an
-    attribute is true, the attribute is included in the tag without a
-    value, if the value is false, the attribute is omitted.  The boolean
-    attributes handled in this way are given by the _booleans parameter,
-    which is a sequence of attribute names.  Its default value is
-    ('checked', 'disabled', 'multiple', 'selected')
-
-    To allow for attribute names that are also python keywords, a single
-    trailing underscore character is removed from an attribute name if
-    it is preset, so that e.g. the class attribute can be specified
-    using the class_ keyword parameters.
-
-    A few attribute names are not valid Python identifiers because they
-    contain a minus-sign (e.g. accept-charset).  However, since there
-    are no attribute names that contain underscores, underscores in a
-    keyword argument will be converted to minus-signs to determine the
-    attribute name.  For instance the accept-charset attribute can be
-    given as accept_charset to this function.
-
-    Examples:
-    >>> from mpulsweb.lib.renderer import tag
-    >>> tag("input", type="text", name="title", disabled=False)
-    '<input type="text" name="title">'
-    >>> 
-    """
-    out = ["<%s" % tagname]
-    for name, value in attrs.items():
-        if name.endswith("_"):
-            name = name[:-1]
-        name = name.replace("_", "-")
-        if name in _booleans:
-            if value:
-                out.append(' %s="%s"' % (name, name))
-        else:
-            if value is None:
-                value = ""
-            elif not isinstance(value, basestring):
-                value = str(value)
-            out.append(' %s="%s"' % (name, escape(value, True)))
-    if _close:
-        out.append(">")
-    else:
-        out.append(">")
-    return "".join(out)
-
 def render_logbook_typeoptions(item):
     out = []
     for i in item.get('options'):



More information about the Mpuls-commits mailing list