Hi,
today I tried to run pootle while pylucene v2.2 is installed on my machine.
Sadly, an exception was raised with the following output:
File "/usr/lib/python2.4/site-packages/Pootle/users.py", line 259, in handle
page = self.getpage(pathwords, session, argdict)
File "/usr/lib/python2.4/site-packages/Pootle/pootle.py", line 325, in getpage
return indexpage.ProjectLanguageIndex(self.potree, projectcode, session)
File "/usr/lib/python2.4/site-packages/Pootle/indexpage.py", line 258, in
__init__ languages = self.getlanguages()
File "/usr/lib/python2.4/site-packages/Pootle/indexpage.py", line 286, in
getlanguages languageitems = [self.getlanguageitem(languagecode, languagename)
for languagecode, lang uagename in languages]
File "/usr/lib/python2.4/site-packages/Pootle/indexpage.py", line 295, in
getlanguageitem language = self.potree.getproject(languagecode,
self.projectcode) File "/usr/lib/python2.4/site-packages/Pootle/potree.py",
line 311, in getproject self.projectcache[languagecode, projectcode] =
projects.TranslationProject(languagecode, projectcode, self)
File "/usr/lib/python2.4/site-packages/Pootle/projects.py", line 115, in
__init__ self.initindex()
File "/usr/lib/python2.4/site-packages/Pootle/projects.py", line 789, in
initindex self.updateindex(pofilename, optimize=False)
File "/usr/lib/python2.4/site-packages/Pootle/projects.py", line 800, in
updateindex pofilenamequery = self.searcher.makeQuery([("pofilename",
pofilename)], True) File
"/usr/lib/python2.4/site-packages/translate/search/indexer/__init__.py", line
556, in makeQuery query = indexer.QueryParser.parse(search, fieldName, analyzer)
TypeError: descriptor 'parse' requires a 'PyLucene.QueryParser' object but
received a 'str'
Since I never tried to use pylucene v1.x with pootle (and installing it would
be quite time consuming), I can only guess that this problem is caused by
changes of the pylucene interface from v1.x to v2.x.
This is also indicated by the following mailing list message:
http://lists.osafoundation.org/pipermail/pylucene-dev/2006-May/001067.html
The attached patch would ignore to use PyLucene v2.x. Thus it would allow
people to run pootle even if PyLucene v2 is installed.
It would be great, if anyone with a working innstallation of PyLucene v1.x
could try, if the current pootle code works with it. This could prove that the
current issue with PyLucene is version-dependent.
Any other ideas?
Should I commit the patch?
regards,
Lars
Index: Pootle/projects.py
===
--- Pootle/projects.py (Revision 6926)
+++ Pootle/projects.py (Arbeitskopie)
@@ -757,9 +757,28 @@
yield self.pofilenames[index]
index += 1
+ def check_indexer(self):
+"""test if there is a supported indexing engine
+
+PyLucene v2.x is not supported yet, since the arguments of QueryParser changed
+see http://lists.osafoundation.org/pipermail/pylucene-dev/2006-May/001067.html
+"""
+if not indexer.HAVE_INDEXER:
+return False
+try:
+lucene_version = indexer.indexer.LUCENE_VERSION
+if lucene_version.startswith("1."):
+return True
+else:
+# PyLucene v2.x is not supported yet
+return False
+except AttributeError:
+# any other indexer is ok
+return True
+
def initindex(self):
"""initializes the search index"""
-if not indexer.HAVE_INDEXER:
+if not self.check_indexer():
return
self.indexdir = os.path.join(self.podir, ".poindex-%s-%s" % (self.projectcode, self.languagecode))
class indexconfig:
@@ -775,7 +794,7 @@
def updateindex(self, pofilename, items=None, optimize=True):
"""updates the index with the contents of pofilename (limit to items if given)"""
-if not indexer.HAVE_INDEXER:
+if not self.check_indexer():
return
pofile = self.pofiles[pofilename]
# check if the pomtime in the index == the latest pomtime
@@ -846,7 +865,7 @@
def indexsearch(self, search, returnfields):
"""returns the results from searching the index with the given search"""
-if not indexer.HAVE_INDEXER:
+if not self.check_indexer():
return False
searchparts = []
if search.searchtext:
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle