Hi, I noticed the Autocomplete widget in gluon/sqlhtml.py does not support the distinct value for the select query. In a project I was working on instead of creating a new category like table I modified the sqlhtml.py to allow for setting a distinct value (default is false) attached is a patch file from mercurial trunk this morning.
Are there any issues with this? Thanks, Brent --
# HG changeset patch # User Brent Zeiben <bzei...@tuheadz.com> # Date 1340642532 21600 # Node ID d545ea44624a80d1f23f212a8f23ce7647dba36a # Parent 22468f606668303251baa88547143ec507faac19 Added Distinct to Autocomplete Widget diff -r 22468f606668 -r d545ea44624a gluon/sqlhtml.py --- a/gluon/sqlhtml.py Sat Jun 23 09:11:55 2012 -0500 +++ b/gluon/sqlhtml.py Mon Jun 25 10:42:12 2012 -0600 @@ -536,7 +536,7 @@ _class = 'string' def __init__(self, request, field, id_field=None, db=None, - orderby=None, limitby=(0,10), + orderby=None, limitby=(0,10), distinct=False, keyword='_autocomplete_%(fieldname)s', min_length=2, help_fields=None, help_string=None): @@ -550,6 +550,7 @@ self.db = db or field._db self.orderby = orderby self.limitby = limitby + self.distinct = distinct self.min_length = min_length self.fields=[field] if id_field: @@ -568,7 +569,8 @@ if self.keyword in self.request.vars: field = self.fields[0] rows = self.db(field.like(self.request.vars[self.keyword]+'%'))\ - .select(orderby=self.orderby,limitby=self.limitby,*self.fields) + .select(orderby=self.orderby,limitby=self.limitby, + distinct=self.distinct,*self.fields) if rows: if self.is_reference: id_field = self.fields[1]