Re: [patch] Respect i18n collection names in search boxes

2006-11-30 Thread Tibor Simko
Hello Ferran:

On Thu, 30 Nov 2006, Ferran Jorba wrote:

> may you consider this patch for inclusion for next release?
> You can see what I'm trying to fix looking at our "Search
> collections:" pull down menu in, for example:

Fixed in CVS.  Thanks for the patch (note that I modified it, because
you should not really replace c and c_name, only c_printable)
and thanks for helping me to close one of our open tasks ;-)


Best regards
-- 
Tibor Simko ** CERN IT-UDS ** Bldg 31-S-014 ** Voice: +41-22-7673527
CERN Document Server **  ** 



Re: [patch] Respect i18n collection names in search boxes

2006-11-30 Thread Ferran Jorba

Sorry, Tibor,

forget the previous patch, it is old; I forgot a 'quilt refresh' ;-(


may you consider this patch for inclusion for next release?
You can see what I'm trying to fix looking at our "Search
collections:" pull down menu in, for example:

http://ddd.uab.es/search.py?sc=1&ln=en&p=&f=&action=Search&cc=rcao


New one is attached.

Ferran
With this patch (tested on 0.91.0.20061116) i18n collection names
are honored.  It is specially important if default collection names
are coded, because they appear short and cryptic for the end user.


Index: cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py
===
--- cds-invenio-0.91.0.20061116.orig/modules/websearch/lib/search_engine.py	2006-11-10 12:22:39.0 +0100
+++ cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py	2006-11-30 12:16:47.0 +0100
@@ -125,15 +125,16 @@
 sre_unicode_uppercase_c = sre.compile(unicode(r"(?u)[??]", "utf-8"))
 sre_unicode_uppercase_n = sre.compile(unicode(r"(?u)[?]", "utf-8"))
 
-def get_alphabetically_ordered_collection_list(level=0):
+def get_alphabetically_ordered_collection_list(ln, level=0):
 """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
(collection name, printable collection name).
Suitable for create_search_box()."""
 out = []
-query = "SELECT id,name FROM collection ORDER BY name ASC"
+query = "SELECT name FROM collection ORDER BY name ASC"
 res = run_sql(query)
-for c_id, c_name in res:
-# make a nice printable name (e.g. truncate c_printable for for long collection names):
+for name in res:
+# make a nice printable name (e.g. truncate c_printable for long collection names in language ln):
+c_name = get_coll_i18nname(name, ln)
 if len(c_name)>30:
 c_printable = c_name[:30] + "..."
 else:
@@ -143,7 +144,7 @@
 out.append([c_name, c_printable])
 return out
 
-def get_nicely_ordered_collection_list(collid=1, level=0):
+def get_nicely_ordered_collection_list(ln, collid=1, level=0):
 """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
(collection name, printable collection name).
Suitable for create_search_box()."""
@@ -152,7 +153,8 @@
 " WHERE c.id=cc.id_son AND cc.id_dad='%s' ORDER BY score DESC" % collid
 res = run_sql(query)
 for c, cid in res:
-# make a nice printable name (e.g. truncate c_printable for for long collection names):
+# make a nice printable name (e.g. truncate c_printable for long collection names in language ln):
+c = get_coll_i18nname(c, ln)
 if len(c)>30:
 c_printable = c[:30] + "..."
 else:
@@ -450,9 +452,9 @@
 
 colls_nicely_ordered = []
 if cfg_nicely_ordered_collection_list:
-colls_nicely_ordered = get_nicely_ordered_collection_list()
+colls_nicely_ordered = get_nicely_ordered_collection_list(ln=ln)
 else:
-colls_nicely_ordered = get_alphabetically_ordered_collection_list()
+colls_nicely_ordered = get_alphabetically_ordered_collection_list(ln=ln)
 
 colls_nice = []
 for (cx, cx_printable) in colls_nicely_ordered:


[patch] Respect i18n collection names in search boxes

2006-11-30 Thread Ferran Jorba

Hi Tibor,

may you consider this patch for inclusion for next release?
You can see what I'm trying to fix looking at our "Search
collections:" pull down menu in, for example:

http://ddd.uab.es/search.py?sc=1&ln=en&p=&f=&action=Search&cc=rcao

Thanks,

Ferran
With this patch (tested on 0.91.0.20061116) i18n collection names
are honored.  It is specially important if default collection names
are coded, because they appear short and cryptic for the end user.


Index: cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py
===
--- cds-invenio-0.91.0.20061116.orig/modules/websearch/lib/search_engine.py	2006-11-10 12:22:39.0 +0100
+++ cds-invenio-0.91.0.20061116/modules/websearch/lib/search_engine.py	2006-11-30 11:30:19.0 +0100
@@ -125,7 +125,7 @@
 sre_unicode_uppercase_c = sre.compile(unicode(r"(?u)[??]", "utf-8"))
 sre_unicode_uppercase_n = sre.compile(unicode(r"(?u)[?]", "utf-8"))
 
-def get_alphabetically_ordered_collection_list(level=0):
+def get_alphabetically_ordered_collection_list(ln, level=0):
 """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
(collection name, printable collection name).
Suitable for create_search_box()."""
@@ -133,7 +133,8 @@
 query = "SELECT id,name FROM collection ORDER BY name ASC"
 res = run_sql(query)
 for c_id, c_name in res:
-# make a nice printable name (e.g. truncate c_printable for for long collection names):
+# make a nice printable name (e.g. truncate c_printable for for long collection names in language ln):
+c_name = get_coll_i18nname(c_id, ln)
 if len(c_name)>30:
 c_printable = c_name[:30] + "..."
 else:
@@ -143,7 +144,7 @@
 out.append([c_name, c_printable])
 return out
 
-def get_nicely_ordered_collection_list(collid=1, level=0):
+def get_nicely_ordered_collection_list(ln, collid=1, level=0):
 """Returns nicely ordered (score respected) list of collections, more exactly list of tuples
(collection name, printable collection name).
Suitable for create_search_box()."""
@@ -450,9 +451,9 @@
 
 colls_nicely_ordered = []
 if cfg_nicely_ordered_collection_list:
-colls_nicely_ordered = get_nicely_ordered_collection_list()
+colls_nicely_ordered = get_nicely_ordered_collection_list(ln=ln)
 else:
-colls_nicely_ordered = get_alphabetically_ordered_collection_list()
+colls_nicely_ordered = get_alphabetically_ordered_collection_list(ln=ln)
 
 colls_nice = []
 for (cx, cx_printable) in colls_nicely_ordered:


CVS Commit Overview for 2006-11-29

2006-11-30 Thread CDS Invenio CVS
CVS Commit Overview for 2006-11-29
==

2006-11-29  Jerome Caffaro 

* modules/websearch/lib/search_engine.py: Fixed bug due to checking
of 'uid' when 'req' object is not available.

2006-11-29  Tibor Simko 

* modules/bibedit/lib/bibedit_engine.py,
modules/bibformat/lib/bibformat_engine.py,
modules/elmsubmit/lib/elmsubmit_EZEmail.py,
modules/websearch/lib/websearch_external_collections_getter.py:
Removed explicit "is" and "is not" comparisons against True/False
singletons, as per PEP 8.

2006-11-29  Gregory Favre 

* po/fr.po: Updated french translation (bibformat and search
external collections were added).

2006-11-29  Tibor Simko 

* modules/miscutil/lib/dbquery.py.wml: When detecting the position
of creation_time column in TABLE STATUS commands in MySQL 4.0, 4.1
and 5.0, use explicit datetime.datetime or str comparisons (due to
MySQLdb 0.9.2) instead of the 'not long' shortcut, because of
possible NULL values.

-- 
CDS Invenio Developers