summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@0d.be>2012-06-05 10:34:37 (GMT)
committerFrédéric Péters <fpeters@0d.be>2012-06-05 10:34:37 (GMT)
commit20baf16413fee7f5242064937a55deeab2f64bca (patch)
treeaefa5b3a7c1719fe31bf303d751bbe5f3d894e70
parentad3ff81c9a1bf93f909837c673f3b09eeeadf470 (diff)
downloadtabellio.searchform-20baf16413fee7f5242064937a55deeab2f64bca.zip
tabellio.searchform-20baf16413fee7f5242064937a55deeab2f64bca.tar.gz
tabellio.searchform-20baf16413fee7f5242064937a55deeab2f64bca.tar.bz2
allow sorting "numbers" with spaces
-rw-r--r--tabellio/searchform/cmpfunctions.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tabellio/searchform/cmpfunctions.py b/tabellio/searchform/cmpfunctions.py
index b8b0e47..fe522b2 100644
--- a/tabellio/searchform/cmpfunctions.py
+++ b/tabellio/searchform/cmpfunctions.py
@@ -1,3 +1,4 @@
+import re
import Missing
from tabellio.documents.typenames import MAPPING
from plone.i18n.normalizer.fr import normalizer
@@ -5,6 +6,11 @@ import tabellio.config.utils
def get_no_as_int(i):
if i:
+ if ' ' in i:
+ try:
+ return int(re.match('\d+', i).group()
+ except ValueError:
+ return 99999
try:
return int(i.split('-')[0])
except ValueError: