allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject git commit: [#5343] Handle 4-part+ artifact links gracefully
Date Thu, 13 Dec 2012 19:49:39 GMT
Updated Branches:
  refs/heads/tv/5343 [created] 2847ebc19


[#5343] Handle 4-part+ artifact links gracefully


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

Branch: refs/heads/tv/5343
Commit: 2847ebc19571f9a7467b801321113ff50a38960a
Parents: c09d674
Author: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Authored: Thu Dec 13 19:48:55 2012 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Thu Dec 13 19:48:55 2012 +0000

----------------------------------------------------------------------
 Allura/allura/model/index.py               |   12 +++++++-----
 Allura/allura/tests/model/test_artifact.py |    1 +
 2 files changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2847ebc1/Allura/allura/model/index.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/index.py b/Allura/allura/model/index.py
index 736a1e1..5772d20 100644
--- a/Allura/allura/model/index.py
+++ b/Allura/allura/model/index.py
@@ -127,22 +127,24 @@ class Shortlink(object):
     def from_links(cls, *links):
         '''Convert a sequence of shortlinks to the matching Shortlink objects'''
         if len(links):
+            result = {}
             # Parse all the links
             parsed_links = dict((link, cls._parse_link(link)) for link in links)
             links_by_artifact = defaultdict(list)
             project_ids = set()
-            for link, d in parsed_links.iteritems():
-                project_ids.add(d['project_id'])
-                links_by_artifact[unquote(d['artifact'])].append(d)
+            for link, d in parsed_links.items():
+                if d:
+                    project_ids.add(d['project_id'])
+                    links_by_artifact[unquote(d['artifact'])].append(d)
+                else:
+                    result[link] = parsed_links.pop(link)
             q = cls.query.find(dict(
                     link={'$in': links_by_artifact.keys()},
                     project_id={'$in': list(project_ids)}
                 ), validate=False)
-            result = {}
             matches_by_artifact = dict(
                 (link, list(matches))
                 for link, matches in groupby(q, key=lambda s:unquote(s.link)))
-            result = {}
             for link, d in parsed_links.iteritems():
                 matches = matches_by_artifact.get(unquote(d['artifact']), [])
                 matches = (

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/2847ebc1/Allura/allura/tests/model/test_artifact.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/model/test_artifact.py b/Allura/allura/tests/model/test_artifact.py
index b00f77a..0a621a7 100644
--- a/Allura/allura/tests/model/test_artifact.py
+++ b/Allura/allura/tests/model/test_artifact.py
@@ -98,6 +98,7 @@ def test_artifactlink():
     assert M.Shortlink.lookup('[TestPage2]')
     assert M.Shortlink.lookup('[wiki:TestPage2]')
     assert M.Shortlink.lookup('[test:wiki:TestPage2]')
+    assert not M.Shortlink.lookup('[test:wiki:TestPage2:foo]')
     assert not M.Shortlink.lookup('[Wiki:TestPage2]')
     assert not M.Shortlink.lookup('[TestPage2_no_such_page]')
     c.project.uninstall_app('wiki')


Mime
View raw message