allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [28/38] git commit: [#4019] ticket:559 Made solr args escape function more efficient
Date Wed, 30 Apr 2014 18:16:00 GMT
[#4019] ticket:559 Made solr args escape function more efficient


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

Branch: refs/heads/master
Commit: 3dec13df7d52b814d7aac5767fe711bb5f70c4a6
Parents: f9eb860
Author: Ferens Dmitriy <ferensdima@gmail.com>
Authored: Tue Mar 18 21:56:18 2014 +0200
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Wed Apr 30 15:55:13 2014 +0000

----------------------------------------------------------------------
 Allura/allura/lib/solr.py | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3dec13df/Allura/allura/lib/solr.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/solr.py b/Allura/allura/lib/solr.py
index e2019eb..e8d9f7b 100644
--- a/Allura/allura/lib/solr.py
+++ b/Allura/allura/lib/solr.py
@@ -41,22 +41,14 @@ escape_rules = {'+': r'\+',
                ';': r'\;'}
 
 
-def escaped_seq(term):
-    """ Yield the next string based on the
-        next character (either this char
-        or escaped version """
-    for char in term:
-        if char in escape_rules.keys():
-            yield escape_rules[char]
-        else:
-            yield char
-
-
 def escape_solr_arg(term):
     """ Apply escaping to the passed in query terms
         escaping special characters like : , etc"""
     term = term.replace('\\', r'\\')   # escape \ first
-    return "".join([nextStr for nextStr in escaped_seq(term)])
+    for char, escaped_char in escape_rules.iteritems():
+        term = term.replace(char, escaped_char)
+
+    return term
 
 
 def make_solr_from_config(push_servers, query_server=None, **kwargs):


Mime
View raw message