[Mailman-checkins] [Git][mailman/mailman][master] 2 commits: Work around click hang issue.

2019-03-20 Thread Mark Sapiro via Mailman-checkins


Mark Sapiro pushed to branch master at GNU Mailman / Mailman Core


Commits:
88d54838 by Mark Sapiro at 2019-03-20T15:43:57Z
Work around click hang issue.

An issue in the interaction between click ctx.exit() and
contextlib.ExitStack has been worked around as suggested at
https://github.com/pallets/click/issues/1134#issuecomment-436308107

Fixes #520

- - - - -
3a1d9a3d by Mark Sapiro at 2019-03-21T00:49:45Z
Merge branch click_fix into master

Work around click hang issue.

Closes #520

See merge request mailman/mailman!477
- - - - -


3 changed files:

- src/mailman/bin/mailman.py
- src/mailman/docs/NEWS.rst
- src/mailman/rest/tests/test_validator.py


Changes:

=
src/mailman/bin/mailman.py
=
@@ -18,7 +18,6 @@
 """The 'mailman' command dispatcher."""
 import click
 
-from contextlib import ExitStack
 from mailman.commands.cli_help import help as help_command
 from mailman.config import config
 from mailman.core.i18n import _
@@ -60,13 +59,14 @@ class Subcommands(click.MultiCommand):
 # This is here to hook command parsing into the Mailman database
 # transaction system.  If the subcommand succeeds, the transaction is
 # committed, otherwise it's aborted.
+# See https://github.com/pallets/click/issues/1134
 def invoke(self, ctx):
-with ExitStack() as resources:
-# If given a bogus subcommand, the database won't have been
-# initialized so there's no transaction to commit.
-if config.db is not None:
-resources.enter_context(transaction())
-return super().invoke(ctx)
+# If given a bogus subcommand, the database won't have been
+# initialized so there's no transaction to commit.
+if config.db is not None:
+with transaction():
+return super().invoke(ctx)
+return super().invoke(ctx) # pragma: missed
 
 # https://github.com/pallets/click/issues/834
 #


=
src/mailman/docs/NEWS.rst
=
@@ -32,6 +32,9 @@ REST
 Command line
 
 * The ``mailman import21`` command now displays import progress.  (Closes #561)
+* An issue with ``mailman subcommand --help`` hanging has been worked around.
+  (Closes #520)
+
 
 3.2.1
 =


=
src/mailman/rest/tests/test_validator.py
=
@@ -134,3 +134,5 @@ class TestValidators(unittest.TestCase):
 ValueError, email_or_regexp_validator, 'foo.example.com')
 self.assertRaises(
 ValueError, email_or_regexp_validator, '^[^@]+(')
+self.assertRaises(
+ValueError, email_or_regexp_validator, '')



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/34b4f1498ad61fd62c287f4e4f4d6de62557c453...3a1d9a3d7c6b1fae8f9e27b8181ea3e1d7c863b2

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/34b4f1498ad61fd62c287f4e4f4d6de62557c453...3a1d9a3d7c6b1fae8f9e27b8181ea3e1d7c863b2
You're receiving this email because of your account on gitlab.com.


___
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org



[Mailman-checkins] [Git][mailman/mailman][master] 2 commits: Add support for falcon 2.0.0a1

2019-03-20 Thread Abhilash Raj via Mailman-checkins


Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core


Commits:
494f8f98 by Abhilash Raj at 2019-03-21T02:46:36Z
Add support for falcon 2.0.0a1

Fix the version constraint for falcon.

- We support falcon version1.0.0, we dont need to pin versions greater 
than
  1.4.0.
- Fix tests and code to support all falcon versions.

- - - - -
de15b816 by Abhilash Raj at 2019-03-21T02:46:36Z
Merge branch fix-falcon into master

Add support for falcon 2.0.0a1

See merge request mailman/mailman!476
- - - - -


4 changed files:

- setup.py
- src/mailman/rest/helpers.py
- src/mailman/rest/tests/test_wsgiapp.py
- src/mailman/rest/wsgiapp.py


Changes:

=
setup.py
=
@@ -109,7 +109,7 @@ case second `m'.  Any other spelling is incorrect.""",
 'atpublic',
 'click>=7.0',
 'dnspython>=1.14.0',
-'falcon>=1.4.0',
+'falcon>1.0.0',
 'flufl.bounce',
 'flufl.i18n>=2.0',
 'flufl.lock>=3.1',


=
src/mailman/rest/helpers.py
=
@@ -144,11 +144,20 @@ class CollectionMixin:
 """
 # Allow falcon's HTTPBadRequest exceptions to percolate up.  They'll
 # get turned into HTTP 400 errors.
-count = request.get_param_as_int('count', min=0)
-page = request.get_param_as_int('page', min=1)
+count = request.get_param_as_int('count')
+page = request.get_param_as_int('page')
 total_size = len(collection)
 if count is None and page is None:
 return 0, total_size, collection
+# TODO(maxking): Count and page should be positive integers. Once
+# falcon 2.0.0 is out and we can jump to it, we can remove this logic
+# and use `min_value` parameter in request.get_param_as_int.
+if count < 0:
+raise falcon.HTTPInvalidParam(
+count, 'count should be a positive integer.')
+if page < 1:
+raise falcon.HTTPInvalidParam(
+page, 'page should be greater than 0.')
 list_start = (page - 1) * count
 list_end = page * count
 return list_start, total_size, collection[list_start:list_end]
@@ -347,6 +356,6 @@ def get_request_params(request):
 # JSONHandler handler to parse json media type, so we can just do
 # `request.media` to return the request params passed as json body.
 if request.content_type.startswith('application/json'):
-return request.media
+return request.media or dict()
 # request.params returns the parameters passed as URL form encoded.
-return request.params
+return request.params or dict()


=
src/mailman/rest/tests/test_wsgiapp.py
=
@@ -48,15 +48,15 @@ class TestSupportedContentType(unittest.TestCase):
 response = requests.post(
 url,
 headers={'Content-Type': 'application/json'},
+json=dict(),
 auth=basic_auth)
 self.assertEqual(response.status_code, 400)
 self.assertEqual(response.headers.get('content-type', None),
  'application/json; charset=UTF-8')
 self.assertEqual(
 response.json(),
-{'title': 'Invalid JSON',
- 'description': 'Could not parse JSON body -'
-' Expecting value: line 1 column 1 (char 0)'}
+{'title': '400 Bad Request',
+ 'description': 'Missing Parameter: mail_host'}
 )
 # Now, let's try to send in json valid json but cause a missing
 # required parameter error.


=
src/mailman/rest/wsgiapp.py
=
@@ -113,7 +113,7 @@ class ObjectRouter:
 # We don't need this method for object-based routing.
 raise NotImplementedError
 
-def find(self, uri):
+def find(self, uri, req=None):
 segments = uri.split(SLASH)
 # Since the path is always rooted at /, skip the first segment, which
 # will always be the empty string.



View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/3a1d9a3d7c6b1fae8f9e27b8181ea3e1d7c863b2...de15b8167245a71797d694990d3053472e25e150

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/compare/3a1d9a3d7c6b1fae8f9e27b8181ea3e1d7c863b2...de15b8167245a71797d694990d3053472e25e150
You're receiving this email because of your account on gitlab.com.


___
Mailman-checkins mailing list
Mailman-checkins@python.org
Unsubscribe: 
https://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org