Log message for revision 120793: - Marked `processInputs` and `setPageEncoding` as deprecated.
Changed: U Zope/trunk/doc/CHANGES.rst UU Zope/trunk/src/Products/Five/browser/decode.py UU Zope/trunk/src/Products/Five/browser/tests/test_decode.py -=- Modified: Zope/trunk/doc/CHANGES.rst =================================================================== --- Zope/trunk/doc/CHANGES.rst 2011-03-08 09:36:31 UTC (rev 120792) +++ Zope/trunk/doc/CHANGES.rst 2011-03-08 09:39:49 UTC (rev 120793) @@ -54,6 +54,10 @@ Restructuring +++++++++++++ +- Five.browser: Marked `processInputs` and `setPageEncoding` as deprecated. + `processInputs` was replaced by the `postProcessInputs` request method and + the charset negotiation done by `setPageEncoding` was never fully supported. + - Factored out the `Products.ZCatalog` and `Products.PluginIndexes` packages into a new `Products.ZCatalog` distribution. Modified: Zope/trunk/src/Products/Five/browser/decode.py =================================================================== --- Zope/trunk/src/Products/Five/browser/decode.py 2011-03-08 09:36:31 UTC (rev 120792) +++ Zope/trunk/src/Products/Five/browser/decode.py 2011-03-08 09:39:49 UTC (rev 120793) @@ -15,6 +15,8 @@ encoding. """ +from warnings import warn + from zope.publisher.browser import isCGI_NAME from zope.i18n.interfaces import IUserPreferredCharsets @@ -34,7 +36,10 @@ """Recursively look for values (e.g. elements of lists, tuples or dicts) and attempt to decode. """ - + warn(u'processInputValue() is deprecated and will be removed in Zope ' + u'2.16.', + DeprecationWarning, stacklevel=2) + if isinstance(value, list): return [processInputValue(v, charsets) for v in value] elif isinstance(value, tuple): @@ -53,14 +58,18 @@ the passed-in list of charsets. If none are passed in, look up the user's preferred charsets. The default is to use utf-8. """ - + warn(u'processInputs() is deprecated and will be removed in Zope 2.16. If ' + u'your view implements IBrowserPage, similar processing is now ' + u'executed automatically.', + DeprecationWarning, stacklevel=2) + if charsets is None: envadapter = IUserPreferredCharsets(request, None) if envadapter is None: charsets = ['utf-8'] else: charsets = envadapter.getPreferredCharsets() or ['utf-8'] - + for name, value in request.form.items(): if not (isCGI_NAME(name) or name.startswith('HTTP_')): request.form[name] = processInputValue(value, charsets) @@ -70,6 +79,10 @@ ZPublisher uses the value of this header to determine how to encode unicode data for the browser. """ + warn(u'setPageEncoding() is deprecated and will be removed in Zope 2.16. ' + u'It is recommended to let the ZPublisher use the default_encoding. ' + u'Please consider setting default-zpublisher-encoding to utf-8.', + DeprecationWarning, stacklevel=2) envadapter = IUserPreferredCharsets(request) charsets = envadapter.getPreferredCharsets() or ['utf-8'] request.RESPONSE.setHeader( Property changes on: Zope/trunk/src/Products/Five/browser/decode.py ___________________________________________________________________ Deleted: svn:keywords - Id Modified: Zope/trunk/src/Products/Five/browser/tests/test_decode.py =================================================================== --- Zope/trunk/src/Products/Five/browser/tests/test_decode.py 2011-03-08 09:36:31 UTC (rev 120792) +++ Zope/trunk/src/Products/Five/browser/tests/test_decode.py 2011-03-08 09:39:49 UTC (rev 120793) @@ -18,7 +18,9 @@ """ Testing processInputs + >>> import warnings >>> from Products.Five.browser.decode import processInputs + >>> charsets = ['iso-8859-1'] >>> class DummyRequest: ... form = {} @@ -27,59 +29,75 @@ Strings are converted to unicode:: >>> request.form['foo'] = u'f\xf6\xf6'.encode('iso-8859-1') - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == u'f\xf6\xf6' True Strings in lists are converted to unicode:: >>> request.form['foo'] = [u'f\xf6\xf6'.encode('iso-8859-1')] - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == [u'f\xf6\xf6'] True Strings in tuples are converted to unicode:: >>> request.form['foo'] = (u'f\xf6\xf6'.encode('iso-8859-1'),) - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == (u'f\xf6\xf6',) True - + Ints in lists are not lost:: >>> request.form['foo'] = [1, 2, 3] - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == [1, 2, 3] True - + Ints in tuples are not lost:: >>> request.form['foo'] = (1, 2, 3,) - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == (1, 2, 3) True - + Mixed lists work: >>> request.form['foo'] = [u'f\xf6\xf6'.encode('iso-8859-1'), 2, 3] - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == [u'f\xf6\xf6', 2, 3] True - + Mixed dicts work: - + >>> request.form['foo'] = {'foo': u'f\xf6\xf6'.encode('iso-8859-1'), 'bar': 2} - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == {'foo': u'f\xf6\xf6', 'bar': 2} True - + Deep recursion works: - + >>> request.form['foo'] = [{'foo': u'f\xf6\xf6'.encode('iso-8859-1'), 'bar': 2}, {'foo': u"one", 'bar': 3}] - >>> processInputs(request, charsets) + >>> with warnings.catch_warnings(): + ... warnings.simplefilter('ignore') + ... processInputs(request, charsets) >>> request.form['foo'] == [{'foo': u'f\xf6\xf6', 'bar': 2}, {'foo': u"one", 'bar': 3}] True - + """ def test_suite(): Property changes on: Zope/trunk/src/Products/Five/browser/tests/test_decode.py ___________________________________________________________________ Deleted: svn:keywords - Id _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org https://mail.zope.org/mailman/listinfo/zope-checkins