Can you please email me the code below as an attachment? massimo
On Dec 20, 10:41 am, Cliff <[email protected]> wrote: > Can someone point to the instructions for submitting a patch? > > I would like to submit a patch for the following code in sqlhtml.py > (starting line 1305) so it will be considered and either rejected or > accepted. > > The change, in my opinion, improves the usability of the grid search > panel by providing a little more instruction and allowing the user to > employ natural language operators. > > Here is the code for any who might be interested. > > @staticmethod > # Allow the user to use natural language comparison operators > def search_menu(fields,search_options=None): > from gluon import current > T = current.T > search_options = search_options or { > # commented out so the following can represent a search > option > # dictionary passed as a parameter > # this example works only for string types > # the values in the search_options dict can contain > strings, lists or tuples > # 'string':['=','!=','<','>','<=','>=','starts > with','contains'], > 'string':[('equals','='), > ('not equal to','!='), > ('less than','<'), > ('greater than','>'), > # ,'<=','>=', > 'starts with', > 'contains'], > # back to the original code > 'text':['=','!=','<','>','<=','>=','starts > with','contains'], > 'date':['=','!=','<','>','<=','>='], > 'time':['=','!=','<','>','<=','>='], > 'datetime':['=','!=','<','>','<=','>='], > 'integer':['=','!=','<','>','<=','>='], > 'double':['=','!=','<','>','<=','>='], > 'boolean':['=','!=']} > if fields[0]._db._adapter.dbengine=='google:datastore': > search_options['string'] = ['=','!=','<','>','<=','>='] > search_options['text'] = ['=','!=','<','>','<=','>='] > criteria = [] > # selectfields = {'':''} > # Improved usability. Don't leave the user figuring out what > to do > # with the empty pulldown. > selectfields = {T('Choose a field.'):''} > for field in fields: > name = str(field).replace('.','-') > criterion = [] > options = search_options.get(field.type,None) > if options: > selectfields[T(field.label)] = str(field) > # couldn't figure out how to do this as a list > comprehension, > # so define the list first > selectoptions=[] > # is the option a list/tuple or a string? > # handle accordingly > for option in options: > if isinstance(option, basestring): > selectoptions.append(OPTION(option, > _value=option)) > else: > selectoptions.append(OPTION(option[0], > _value=option[1])) > # operators = SELECT(*[T(option) for option in > options]) > # now build the operators pulldown > operators = SELECT(selectoptions) > # end of changes > . > . > .

