Hello community, here is the log from the commit of package python3-CherryPy for openSUSE:Factory checked in at 2016-07-21 08:19:37 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-CherryPy (Old) and /work/SRC/openSUSE:Factory/.python3-CherryPy.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-CherryPy" Changes: -------- --- /work/SRC/openSUSE:Factory/python3-CherryPy/python3-CherryPy.changes 2016-07-18 21:25:43.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python3-CherryPy.new/python3-CherryPy.changes 2016-07-21 08:19:40.000000000 +0200 @@ -1,0 +2,11 @@ +Wed Jul 20 15:01:05 UTC 2016 - a...@gmx.de + +- update to version 6.2.0: + * #1441: Added tool to automatically convert request params based on + type annotations (primarily in Python 3). + +- changes from version 6.1.1: + * Issue #1411: Fix issue where autoreload fails when the host + interpreter for CherryPy was launched using "python -m". + +------------------------------------------------------------------- Old: ---- CherryPy-6.1.0.tar.gz New: ---- CherryPy-6.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-CherryPy.spec ++++++ --- /var/tmp/diff_new_pack.7Glw6h/_old 2016-07-21 08:19:41.000000000 +0200 +++ /var/tmp/diff_new_pack.7Glw6h/_new 2016-07-21 08:19:41.000000000 +0200 @@ -17,7 +17,7 @@ Name: python3-CherryPy -Version: 6.1.0 +Version: 6.2.0 Release: 0 Url: http://www.cherrypy.org Summary: Object-Oriented HTTP framework ++++++ CherryPy-6.1.0.tar.gz -> CherryPy-6.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/CherryPy.egg-info/PKG-INFO new/CherryPy-6.2.0/CherryPy.egg-info/PKG-INFO --- old/CherryPy-6.1.0/CherryPy.egg-info/PKG-INFO 2016-07-14 06:59:15.000000000 +0200 +++ new/CherryPy-6.2.0/CherryPy.egg-info/PKG-INFO 2016-07-19 03:06:17.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: CherryPy -Version: 6.1.0 +Version: 6.2.0 Summary: Object-Oriented HTTP framework Home-page: http://www.cherrypy.org Author: CherryPy Team diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/CherryPy.egg-info/SOURCES.txt new/CherryPy-6.2.0/CherryPy.egg-info/SOURCES.txt --- old/CherryPy-6.1.0/CherryPy.egg-info/SOURCES.txt 2016-07-14 06:59:15.000000000 +0200 +++ new/CherryPy-6.2.0/CherryPy.egg-info/SOURCES.txt 2016-07-19 03:06:17.000000000 +0200 @@ -96,6 +96,7 @@ cherrypy/test/test_mime.py cherrypy/test/test_misc_tools.py cherrypy/test/test_objectmapping.py +cherrypy/test/test_params.py cherrypy/test/test_proxy.py cherrypy/test/test_refleaks.py cherrypy/test/test_request_obj.py diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/PKG-INFO new/CherryPy-6.2.0/PKG-INFO --- old/CherryPy-6.1.0/PKG-INFO 2016-07-14 06:59:15.000000000 +0200 +++ new/CherryPy-6.2.0/PKG-INFO 2016-07-19 03:06:17.000000000 +0200 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: CherryPy -Version: 6.1.0 +Version: 6.2.0 Summary: Object-Oriented HTTP framework Home-page: http://www.cherrypy.org Author: CherryPy Team diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/cherrypy/_cptools.py new/CherryPy-6.2.0/cherrypy/_cptools.py --- old/CherryPy-6.1.0/cherrypy/_cptools.py 2016-07-14 06:57:35.000000000 +0200 +++ new/CherryPy-6.2.0/cherrypy/_cptools.py 2016-07-19 03:04:51.000000000 +0200 @@ -533,5 +533,6 @@ _d.json_out = Tool('before_handler', jsontools.json_out, priority=30) _d.auth_basic = Tool('before_handler', auth_basic.basic_auth, priority=1) _d.auth_digest = Tool('before_handler', auth_digest.digest_auth, priority=1) +_d.params = Tool('before_handler', cptools.convert_params) del _d, cptools, encoding, auth, static diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/cherrypy/lib/cptools.py new/CherryPy-6.2.0/cherrypy/lib/cptools.py --- old/CherryPy-6.1.0/cherrypy/lib/cptools.py 2016-07-14 06:57:35.000000000 +0200 +++ new/CherryPy-6.2.0/cherrypy/lib/cptools.py 2016-07-19 03:04:51.000000000 +0200 @@ -630,3 +630,21 @@ v.sort() resp_h['Vary'] = ', '.join(v) request.hooks.attach('before_finalize', set_response_header, 95) + + +def convert_params(exception=ValueError, error=400): + """Convert request params based on function annotations, with error handling. + + exception + Exception class to catch. + + status + The HTTP error code to return to the client on failure. + """ + request = cherrypy.serving.request + types = request.handler.callable.__annotations__ + try: + for key in set(types).intersection(request.params): + request.params[key] = types[key](request.params[key]) + except exception as exc: + raise cherrypy.HTTPError(error, str(exc)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/cherrypy/process/wspbus.py new/CherryPy-6.2.0/cherrypy/process/wspbus.py --- old/CherryPy-6.1.0/cherrypy/process/wspbus.py 2016-07-14 06:57:35.000000000 +0200 +++ new/CherryPy-6.2.0/cherrypy/process/wspbus.py 2016-07-19 03:04:51.000000000 +0200 @@ -379,6 +379,8 @@ args = sys.argv[:] self.log('Re-spawning %s' % ' '.join(args)) + self._extend_pythonpath(os.environ) + if sys.platform[:4] == 'java': from _systemrestart import SystemRestart raise SystemRestart @@ -392,6 +394,30 @@ self._set_cloexec() os.execv(sys.executable, args) + @staticmethod + def _extend_pythonpath(env): + """ + If sys.path[0] is an empty string, the interpreter was likely + invoked with -m and the effective path is about to change on + re-exec. Add the current directory to $PYTHONPATH to ensure + that the new process sees the same path. + + This issue cannot be addressed in the general case because + Python cannot reliably reconstruct the + original command line (http://bugs.python.org/issue14208). + + (This idea filched from tornado.autoreload) + """ + path_prefix = '.' + os.pathsep + existing_path = env.get('PYTHONPATH', '') + needs_patch = ( + sys.path[0] == '' and + not existing_path.startswith(path_prefix) + ) + + if needs_patch: + env["PYTHONPATH"] = path_prefix + existing_path + def _set_cloexec(self): """Set the CLOEXEC flag on all open files (except stdin/out/err). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/cherrypy/test/test_params.py new/CherryPy-6.2.0/cherrypy/test/test_params.py --- old/CherryPy-6.1.0/cherrypy/test/test_params.py 1970-01-01 01:00:00.000000000 +0100 +++ new/CherryPy-6.2.0/cherrypy/test/test_params.py 2016-07-19 03:04:51.000000000 +0200 @@ -0,0 +1,60 @@ +import sys +import textwrap + +import cherrypy +from cherrypy.test import helper + + +class ParamsTest(helper.CPWebCase): + @staticmethod + def setup_server(): + class Root: + @cherrypy.expose + @cherrypy.tools.params() + def resource(self, limit=None, sort=None): + return type(limit).__name__ + # for testing on Py 2 + resource.__annotations__ = {'limit': int} + conf = {'/': {'tools.params.on': True}} + cherrypy.tree.mount(Root(), config=conf) + + def test_pass(self): + self.getPage('/resource') + self.assertStatus(200) + self.assertBody('NoneType') + + self.getPage('/resource?limit=0') + self.assertStatus(200) + self.assertBody('int') + + def test_error(self): + self.getPage('/resource?limit=') + self.assertStatus(400) + self.assertInBody('invalid literal for int') + + cherrypy.config['tools.params.error'] = 422 + self.getPage('/resource?limit=') + self.assertStatus(422) + self.assertInBody('invalid literal for int') + + cherrypy.config['tools.params.exception'] = TypeError + self.getPage('/resource?limit=') + self.assertStatus(500) + + def test_syntax(self): + if sys.version_info < (3,): + return self.skip("skipped (Python 3 only)") + code = textwrap.dedent(""" + class Root: + @cherrypy.expose + @cherrypy.tools.params() + def resource(self, limit: int): + return type(limit).__name__ + conf = {'/': {'tools.params.on': True}} + cherrypy.tree.mount(Root(), config=conf) + """) + exec(code) + + self.getPage('/resource?limit=0') + self.assertStatus(200) + self.assertBody('int') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/setup.cfg new/CherryPy-6.2.0/setup.cfg --- old/CherryPy-6.1.0/setup.cfg 2016-07-14 06:59:15.000000000 +0200 +++ new/CherryPy-6.2.0/setup.cfg 2016-07-19 03:06:17.000000000 +0200 @@ -1,5 +1,5 @@ [bumpversion] -current_version = 6.1.0 +current_version = 6.2.0 commit = True tag = True diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CherryPy-6.1.0/setup.py new/CherryPy-6.2.0/setup.py --- old/CherryPy-6.1.0/setup.py 2016-07-14 06:57:35.000000000 +0200 +++ new/CherryPy-6.2.0/setup.py 2016-07-19 03:04:51.000000000 +0200 @@ -25,7 +25,7 @@ # arguments for the setup command ############################################################################### name = "CherryPy" -version = "6.1.0" +version = "6.2.0" desc = "Object-Oriented HTTP framework" long_desc = "CherryPy is a pythonic, object-oriented HTTP framework" classifiers = [