Op Dinsdag 03-07-2007 om 23:28 uur [tijdzone +0200], schreef Nicolas
François:
> On Tue, Jul 03, 2007 at 09:24:48PM +0300, Stoyan Angelov wrote:
> > hello all,
> > 
...

> 
> The keyword arguments were introduced in Python 2.4's sort. The easiest
> fix would be to update your python version.
> 
> If you cannot do that, you can change that line in indexpage.py by:
>         languages.sort(lambda x,y: locale.strcoll(x["name"], y["name"]))
> 
> Maybe this could also be used in vanilla pootle since it is compatible
> with both python2.3 and python2.4.
> 
> Note that there may also be other issues with python2.3.
> 
> Kind Regards,

Sorry, I missed this one for Pootle 1.0.2. I'm attaching the diff I have
to do this. Can somebody with Python 2.3 please test it?

Stoyan, does everything work fine now with Python 2.3 and the changes
Nicolas suggested? Which python version and implementation are you
using?

I seem to have some other problems with Python 2.3, though (I'm using
cPython 2.3.6). I get the following traceback. So if people really still
need to run Pootle with Python 2.3, I guess somebody should look at
this:

  File "/home/f/download/translate/src/Pootle/users.py", line 239, in handle
    page = self.getpage(pathwords, session, argdict)
  File "/home/f/download/translate/src/Pootle/pootle.py", line 356, in getpage
    return indexpage.UserIndex(self.potree, session)
  File "/home/f/download/translate/src/Pootle/indexpage.py", line 147, in 
__init__
    quicklinks = self.getquicklinks()
  File "/home/f/download/translate/src/Pootle/indexpage.py", line 167, in 
getquicklinks
    project = self.potree.getproject(languagecode, projectcode)
  File "/home/f/download/translate/src/Pootle/potree.py", line 311, in 
getproject
    self.projectcache[languagecode, projectcode] = 
projects.TranslationProject(languagecode, projectcode, self)
  File "/home/f/download/translate/src/Pootle/projects.py", line 116, in 
__init__
    self.initindex()
  File "/home/f/download/translate/src/Pootle/projects.py", line 767, in 
initindex
    self.analyzer = indexer.PerFieldAnalyzer([("pofilename", 
indexer.ExactAnalyzer())])
  File "/home/f/python/lib/python/jToolkit/data/indexer.py", line 272, in 
__init__
    defaultanalyzer = StandardAnalyzer()
  File "/home/f/python/lib/python/jToolkit/data/indexer.py", line 184, in 
StandardAnalyzer
    return indexer.StandardAnalyzer()
AttributeError: 'module' object has no attribute 'StandardAnalyzer'


The toolkit also wasn't doing so well with Python 2.3 anymore. There are
a few things that were broken. I fixed almost all of them now in SVN. So
translate toolkit 1.1 should also work better again with Python 2.3,
although not 100%.

Anybody still using Python 2.2?
Index: users.py
===================================================================
--- users.py	(revision 6098)
+++ users.py	(working copy)
@@ -195,7 +195,9 @@
     languages = []
     for language, name in languageoptions:
       languages.append({"code": language, "name": self.tr_lang(name), "selected": language in userlanguages or None})
-    languages.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    # rewritten for compatibility with Python 2.3
+    # languages.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    languages.sort(lambda x,y: locale.strcoll(x["name"], y["name"]))
     return languages
 
   def getotheroptions(self):
@@ -209,7 +211,9 @@
       if code == "templates":
         continue
       languageoptions.append({"code": code, "name": self.tr_lang(name), "selected": uilanguage == code or None})
-    languageoptions.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    # rewritten for compatibility with Python 2.3
+    # languageoptions.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    languageoptions.sort(lambda x,y: locale.strcoll(x["name"], y["name"]))
     options = {"inputheight": self.localize("Input Height (in lines)"), 
           "viewrows": self.localize("Number of rows in view mode"), 
           "translaterows": self.localize("Number of rows in translate mode")}
Index: indexpage.py
===================================================================
--- indexpage.py	(revision 6098)
+++ indexpage.py	(working copy)
@@ -102,7 +102,9 @@
     pagetitle = instancetitle
     sessionvars = {"status": session.status, "isopen": session.isopen, "issiteadmin": session.issiteadmin()}
     languages = [{"code": code, "name": self.tr_lang(name), "sep": ", "} for code, name in self.potree.getlanguages()]
-    languages.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    # rewritten for compatibility with Python 2.3
+    # languages.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+    languages.sort(lambda x,y: locale.strcoll(x["name"], y["name"]))
     if languages:
       languages[-1]["sep"] = ""
     templatevars = {"pagetitle": pagetitle, "description": description, 
@@ -170,7 +172,9 @@
       if langlinks:
         langlinks[-1]["sep"] = ""
       quicklinks.append({"code": languagecode, "name": self.tr_lang(languagename), "projects": langlinks})
-      quicklinks.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+      # rewritten for compatibility with Python 2.3
+      # quicklinks.sort(cmp=locale.strcoll, key=lambda dict: dict["name"])
+      quicklinks.sort(lambda x,y: locale.strcoll(x["name"], y["name"]))
     return quicklinks
 
 class ProjectsIndex(PootleIndex):
@@ -286,7 +290,9 @@
     languages = self.potree.getlanguages(self.projectcode)
     self.languagecount = len(languages)
     languageitems = [self.getlanguageitem(languagecode, languagename) for languagecode, languagename in languages]
-    languageitems.sort(cmp=locale.strcoll, key=lambda dict: dict["title"])
+    # rewritten for compatibility with Python 2.3
+    # languageitems.sort(cmp=locale.strcoll, key=lambda dict: dict["title"])
+    languageitems.sort(lambda x,y: locale.strcoll(x["title"], y["title"]))
     for n, item in enumerate(languageitems):
       item["parity"] = ["even", "odd"][n % 2]
     return languageitems
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Translate-pootle mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/translate-pootle

Reply via email to