You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2014/04/05 00:01:38 UTC

[1/2] git commit: [#7307] Bumped Ming version for better handling of large error messages

Repository: allura
Updated Branches:
  refs/heads/master b227c3f36 -> 5f26ae662


[#7307] Bumped Ming version for better handling of large error messages

Signed-off-by: Cory Johns <cj...@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/5f26ae66
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/5f26ae66
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/5f26ae66

Branch: refs/heads/master
Commit: 5f26ae66217cd3638082f28ecb3de00833c35be0
Parents: 2c88f7d
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Fri Apr 4 16:19:33 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 4 22:01:22 2014 +0000

----------------------------------------------------------------------
 requirements-common.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/5f26ae66/requirements-common.txt
----------------------------------------------------------------------
diff --git a/requirements-common.txt b/requirements-common.txt
index 2e2d0b5..b1163cf 100644
--- a/requirements-common.txt
+++ b/requirements-common.txt
@@ -21,7 +21,7 @@ httplib2==0.7.4
 iso8601==0.1.4
 Jinja2==2.6
 Markdown==2.2.0
-Ming==0.4.4
+Ming==0.4.6
 oauth2==1.5.170
 # tg2 dep PasteDeploy must specified before TurboGears2, to avoid a version/allow-hosts problem
 Paste==1.7.5.1


[2/2] git commit: [#7307] safer 'doc too large' checking, to account for ming's arg injection

Posted by jo...@apache.org.
[#7307] safer 'doc too large' checking, to account for ming's arg injection


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/2c88f7d7
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/2c88f7d7
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/2c88f7d7

Branch: refs/heads/master
Commit: 2c88f7d749c607537f63942e1955c5fa85958dcb
Parents: b227c3f
Author: Dave Brondsema <db...@slashdotmedia.com>
Authored: Thu Apr 3 15:21:13 2014 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Fri Apr 4 22:01:22 2014 +0000

----------------------------------------------------------------------
 Allura/allura/command/show_models.py     | 2 +-
 Allura/allura/model/session.py           | 2 +-
 Allura/allura/tests/test_commands.py     | 5 ++++-
 Allura/allura/tests/unit/test_session.py | 5 ++++-
 4 files changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/2c88f7d7/Allura/allura/command/show_models.py
----------------------------------------------------------------------
diff --git a/Allura/allura/command/show_models.py b/Allura/allura/command/show_models.py
index 76d95ac..36aa29e 100644
--- a/Allura/allura/command/show_models.py
+++ b/Allura/allura/command/show_models.py
@@ -177,7 +177,7 @@ class ReindexCommand(base.Command):
         except InvalidDocument as e:
             # there are many types of InvalidDocument, only recurse if its
             # expected to help
-            if str(e).startswith('BSON document too large'):
+            if e.args[0].startswith('BSON document too large'):
                 self._post_add_artifacts(chunk[:len(chunk) // 2])
                 self._post_add_artifacts(chunk[len(chunk) // 2:])
             else:

http://git-wip-us.apache.org/repos/asf/allura/blob/2c88f7d7/Allura/allura/model/session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/session.py b/Allura/allura/model/session.py
index 50bbb8a..ca5db5a 100644
--- a/Allura/allura/model/session.py
+++ b/Allura/allura/model/session.py
@@ -162,7 +162,7 @@ class BatchIndexer(ArtifactSessionExtension):
         except pymongo.errors.InvalidDocument as e:
             # there are many types of InvalidDocument, only recurse if its
             # expected to help
-            if str(e).startswith('BSON document too large'):
+            if e.args[0].startswith('BSON document too large'):
                 cls._post(task_func, chunk[:len(chunk) // 2])
                 cls._post(task_func, chunk[len(chunk) // 2:])
             else:

http://git-wip-us.apache.org/repos/asf/allura/blob/2c88f7d7/Allura/allura/tests/test_commands.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/test_commands.py b/Allura/allura/tests/test_commands.py
index 1ecfb39..73b419a 100644
--- a/Allura/allura/tests/test_commands.py
+++ b/Allura/allura/tests/test_commands.py
@@ -442,8 +442,11 @@ class TestReindexCommand(object):
     def test_post_add_artifacts_too_large(self, add_artifacts):
         def on_post(chunk, **kw):
             if len(chunk) > 1:
-                raise pymongo.errors.InvalidDocument(
+                e = pymongo.errors.InvalidDocument(
                     "BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
+                # ming injects a 2nd arg with the document, so we do too
+                e.args = e.args + ("doc:  {'task_name': 'allura.tasks.index_tasks.add_artifacts', ........",)
+                raise e
         add_artifacts.post.side_effect = on_post
         cmd = show_models.ReindexCommand('reindex')
         cmd.options, args = cmd.parser.parse_args([])

http://git-wip-us.apache.org/repos/asf/allura/blob/2c88f7d7/Allura/allura/tests/unit/test_session.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/unit/test_session.py b/Allura/allura/tests/unit/test_session.py
index f9bd277..eec41bd 100644
--- a/Allura/allura/tests/unit/test_session.py
+++ b/Allura/allura/tests/unit/test_session.py
@@ -142,8 +142,11 @@ class TestBatchIndexer(TestCase):
     def test__post_too_large(self, index_tasks):
         def on_post(chunk):
             if len(chunk) > 1:
-                raise pymongo.errors.InvalidDocument(
+                e = pymongo.errors.InvalidDocument(
                     "BSON document too large (16906035 bytes) - the connected server supports BSON document sizes up to 16777216 bytes.")
+                # ming injects a 2nd arg with the document, so we do too
+                e.args = e.args + ("doc:  {'task_name': 'allura.tasks.index_tasks.add_artifacts', ........",)
+                raise e
         index_tasks.add_artifacts.post.side_effect = on_post
         self.ext._post(index_tasks.add_artifacts, range(5))
         expected = [