Check do_post_sort attribute on source to be able to disable the sorting.

This commit is contained in:
Vincent Fretin 2013-08-30 18:11:22 +02:00
parent 4b42da9439
commit 02a0a792ee
2 changed files with 8 additions and 3 deletions

View File

@ -5,6 +5,8 @@ Changelog
1.0 (unreleased)
----------------
- Check do_post_sort attribute on source to be able to disable the sorting.
- Declare dependencies on z3c.relationfield and plone.formwidget.contenttree.
- Remove ploneform-render-widget view for content provider, this is now

View File

@ -279,9 +279,12 @@ class AutocompleteSearch(BaseAutocompleteSearch):
query = "path:%s %s" % (source.tokenToPath(path), query)
if query:
terms = set(source.search(query))
terms = source.search(query)
else:
terms = set()
terms = ()
if getattr(source, 'do_post_sort', True):
terms = sorted(set(terms), key=lambda t: t.title)
return u'\n'.join([u"|".join((t.token, t.title or t.token, t.portal_type, t.url, t.extra))
for t in sorted(terms, key=lambda t: t.title)])
for t in terms])