[Erp5-report] r43909 gregory - /erp5/trunk/products/ERP5Type/patches/make_hidden_input.py

nobody at svn.erp5.org nobody at svn.erp5.org
Wed Mar 2 17:45:44 CET 2011


Author: gregory
Date: Wed Mar  2 17:45:44 2011
New Revision: 43909

URL: http://svn.erp5.org?rev=43909&view=rev
Log:
Make make_hidden_input produce valid X-HTML <input /> tag.

Modified:
    erp5/trunk/products/ERP5Type/patches/make_hidden_input.py

Modified: erp5/trunk/products/ERP5Type/patches/make_hidden_input.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5Type/patches/make_hidden_input.py?rev=43909&r1=43908&r2=43909&view=diff
==============================================================================
--- erp5/trunk/products/ERP5Type/patches/make_hidden_input.py [utf8] (original)
+++ erp5/trunk/products/ERP5Type/patches/make_hidden_input.py [utf8] Wed Mar  2 17:45:44 2011
@@ -14,41 +14,40 @@
 
 """
 Backport fix from https://bugs.launchpad.net/zope2/+bug/143768 for Zope2.8
+Also, close properly the <input /> tag
 """
 
-from App import version_txt
-if version_txt.getZopeVersion() < (2, 9):
-  import ZTUtils.Zope
-  from ZTUtils.Zope import complex_marshal
-  import cgi
-
-  def make_hidden_input(*args, **kwargs):
-      '''Construct a set of hidden input elements, with marshalling markup.
-
-      If there are positional arguments, they must be dictionaries.
-      They are combined with the dictionary of keyword arguments to form
-      a dictionary of query names and values.
-
-      Query names (the keys) must be strings.  Values may be strings,
-      integers, floats, or DateTimes, and they may also be lists or
-      namespaces containing these types.  All arguments are marshalled with
-      complex_marshal().
-      '''
-
-      d = {}
-      for arg in args:
-          d.update(arg)
-      d.update(kwargs)
-
-      hq = lambda x:cgi.escape(x, quote=True)
-      qlist = complex_marshal(d.items())
-      for i in range(len(qlist)):
-          k, m, v = qlist[i]
-          qlist[i] = ('<input type="hidden" name="%s%s" value="%s">'
-                      % (hq(k), m, hq(str(v))))
+import ZTUtils.Zope
+from ZTUtils.Zope import complex_marshal
+import cgi
+
+def make_hidden_input(*args, **kwargs):
+  '''Construct a set of hidden input elements, with marshalling markup.
+
+  If there are positional arguments, they must be dictionaries.
+  They are combined with the dictionary of keyword arguments to form
+  a dictionary of query names and values.
+
+  Query names (the keys) must be strings.  Values may be strings,
+  integers, floats, or DateTimes, and they may also be lists or
+  namespaces containing these types.  All arguments are marshalled with
+  complex_marshal().
+  '''
+
+  d = {}
+  for arg in args:
+      d.update(arg)
+  d.update(kwargs)
+
+  hq = lambda x:cgi.escape(x, quote=True)
+  qlist = complex_marshal(d.items())
+  for i in range(len(qlist)):
+      k, m, v = qlist[i]
+      qlist[i] = ('<input type="hidden" name="%s%s" value="%s" />'
+                  % (hq(k), m, hq(str(v))))
 
-      return '\n'.join(qlist)
+  return '\n'.join(qlist)
 
-  ZTUtils.Zope.make_hidden_input = make_hidden_input
-  ZTUtils.make_hidden_input = make_hidden_input
+ZTUtils.Zope.make_hidden_input = make_hidden_input
+ZTUtils.make_hidden_input = make_hidden_input
 



More information about the Erp5-report mailing list