From 89fe9e6871292e76bc9df8731cc1d051024bd2f6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Wed, 17 Mar 2010 15:16:22 +0000
Subject: [PATCH] Backport fix from
 https://bugs.launchpad.net/zope2/+bug/143768 for Zope2.8 This is a proper fix
 for testSimpleRelationFieldWheelButtonQuotedFields

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@33807 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 product/ERP5Type/ZopePatch.py                 |  1 +
 product/ERP5Type/patches/make_hidden_input.py | 52 +++++++++++++++++++
 2 files changed, 53 insertions(+)
 create mode 100644 product/ERP5Type/patches/make_hidden_input.py

diff --git a/product/ERP5Type/ZopePatch.py b/product/ERP5Type/ZopePatch.py
index 817384bbcf..93cda8bd02 100644
--- a/product/ERP5Type/ZopePatch.py
+++ b/product/ERP5Type/ZopePatch.py
@@ -58,6 +58,7 @@ from Products.ERP5Type.patches import memcache_client
 from Products.ERP5Type.patches import StateChangeInfoPatch
 from Products.ERP5Type.patches import transforms
 from Products.ERP5Type.patches import OFSPdata
+from Products.ERP5Type.patches import make_hidden_input
 # BACK: Forward Compatibility with Zope 2.12 or CMF 2.2. Remove when we've
 # dropped support for older versions.
 from Products.ERP5Type.patches import TransactionAddBeforeCommitHook
diff --git a/product/ERP5Type/patches/make_hidden_input.py b/product/ERP5Type/patches/make_hidden_input.py
new file mode 100644
index 0000000000..c2376db43c
--- /dev/null
+++ b/product/ERP5Type/patches/make_hidden_input.py
@@ -0,0 +1,52 @@
+##############################################################################
+#
+# Copyright (c) 2002 Zope Corporation and Contributors. All Rights Reserved.
+
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE
+#
+##############################################################################
+
+"""
+Backport fix from https://bugs.launchpad.net/zope2/+bug/143768 for Zope2.8
+"""
+
+from App import version_txt
+if version_txt.getZopeVersion() < (2, 9):
+  import ZTUtils.Zope
+  from ZTUtils.Zope import complex_marshal
+
+  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)
+
+  ZTUtils.Zope.make_hidden_input = make_hidden_input
+  print 'patching'
-- 
2.30.9