• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

allura


Commit MetaInfo

Révision4b355d125835dbba745bcaa00a4f855e762c1c4e (tree)
l'heure2012-03-02 00:44:25
AuteurDave Brondsema <dbrondsema@geek...>
CommiterCory Johns

Message de Log

[#3824] don't do extra set_context lookup attempts if an ObjectId was used

Signed-off-by: Dave Brondsema <dbrondsema@geek.net>

Change Summary

Modification

--- a/Allura/allura/lib/helpers.py
+++ b/Allura/allura/lib/helpers.py
@@ -174,7 +174,7 @@ def set_context(project_shortname_or_id, mount_point=None, app_config_id=None, n
174174 p = model.Project.query.get(_id=ObjectId(str(project_shortname_or_id)))
175175 except InvalidId:
176176 p = None
177- if p is None:
177+ if p is None and type(project_shortname_or_id) != ObjectId:
178178 if neighborhood is None:
179179 raise TypeError('neighborhood is required; it must not be None')
180180 if not isinstance(neighborhood, model.Neighborhood):
--- a/Allura/allura/tests/unit/test_helpers/test_set_context.py
+++ b/Allura/allura/tests/unit/test_helpers/test_set_context.py
@@ -1,5 +1,6 @@
11 from nose.tools import assert_raises
22 from pylons import c
3+from bson import ObjectId
34
45 from allura.lib.helpers import set_context
56 from allura.lib.exceptions import NoSuchProjectError, NoSuchNeighborhoodError
@@ -79,6 +80,13 @@ class TestWhenProjectIsNotFound(WithDatabase):
7980 'myproject',
8081 neighborhood=nbhd)
8182
83+ def test_proper_exception_when_id_lookup(self):
84+ nbhd = create_neighborhood()
85+ assert_raises(NoSuchProjectError,
86+ set_context,
87+ ObjectId(),
88+ neighborhood=None)
89+
8290 class TestWhenNeighborhoodIsNotFound(WithDatabase):
8391
8492 def test_that_it_raises_an_exception(self):