diff rhodecode/lib/indexers/__init__.py @ 2319:4c239e0dcbb7 beta

fixes issue #454 Search results under Windows include preceeding backslash
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 20 May 2012 16:38:00 +0200
parents 8ecfed1d8f8b
children 1828eb7fa688
line wrap: on
line diff
--- a/rhodecode/lib/indexers/__init__.py	Sun May 20 14:41:03 2012 +0200
+++ b/rhodecode/lib/indexers/__init__.py	Sun May 20 16:38:00 2012 +0200
@@ -129,13 +129,15 @@
                           default=False)
 
 
-class ResultWrapper(object):
-    def __init__(self, search_type, searcher, matcher, highlight_items):
+class WhooshResultWrapper(object):
+    def __init__(self, search_type, searcher, matcher, highlight_items,
+                 repo_location):
         self.search_type = search_type
         self.searcher = searcher
         self.matcher = matcher
         self.highlight_items = highlight_items
         self.fragment_size = 200
+        self.repo_location = repo_location
 
     @LazyProperty
     def doc_ids(self):
@@ -178,8 +180,9 @@
 
     def get_full_content(self, docid):
         res = self.searcher.stored_fields(docid[0])
-        f_path = res['path'][res['path'].find(res['repository']) \
-                             + len(res['repository']):].lstrip('/')
+        full_repo_path = jn(self.repo_location, res['repository'])
+        f_path = res['path'].split(full_repo_path)[-1]
+        f_path = f_path.lstrip(os.sep)
 
         content_short = self.get_short_content(res, docid[1])
         res.update({'content_short': content_short,