Re: [translate-pootle] PyLucene v2 support

2008-01-23 Thread Lars Kruse
Hi,

> The current code definitely still works with PyLucene 1.9.1 which I have
> here. I also tried with your patch applied, and it continued to work.

thanks for testing!


> > Should I commit the patch?
> 
> Yes, please apply.

ok - I did it


> I would however like it if we can upgrade to the
> newer API, as the installation of the older versions are horrible, and I
> guess we are missing out on several improvements to PyLucene made since
> those old versions. But I guess this is what you are busy with, right?

yes - but these changes will take place in the toolkit.
As far as I can see, the current state of the pootle code will "magically"
start working again with PyLucene v2, as soon as a new toolkit with these
changes will be released. This will take some more effort for me, but I want to
do it very soon ...

regards,
Lars

-
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


Re: [translate-pootle] PyLucene v2 support

2008-01-23 Thread F Wolff
Op Woensdag 2008-01-23 skryf Lars Kruse:
> Hi,

Hi Lars

> today I tried to run pootle while pylucene v2.2 is installed on my machine.
> 
> Sadly, an exception was raised with the following output:

I remember Nicolas already pointing out some API change with the version
change to PyLucene 2

> 
> 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.

The current code definitely still works with PyLucene 1.9.1 which I have
here. I also tried with your patch applied, and it continued to work.

> 
> Any other ideas?
> 
> Should I commit the patch?

Yes, please apply. I would however like it if we can upgrade to the
newer API, as the installation of the older versions are horrible, and I
guess we are missing out on several improvements to PyLucene made since
those old versions. But I guess this is what you are busy with, right?

Thank you for the work on this.

Keep well
Friedel


-
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


[translate-pootle] PyLucene v2 support

2008-01-22 Thread Lars Kruse
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