def __format_columns(column_names, sort_field):
 dataset = []
 if (sort_field is not None):
  sort_name = sort_field
 else:
  sort_name = 'name'
 if sort_name.startswith('!'):
  sort_name = sort_name[1:]
  sort_order = 'desc'
 else:
  sort_order = 'asc'
 for fieldname in column_names:
  fieldorder = 'none'
  if (fieldname == sort_name):
   fieldorder = sort_order
  dataset.append([fieldname, fieldorder])
 return dataset

def __format_columns ( column_names , sort_field ) : dataset = [ ] if ( sort_field is not None ) : sort_name = sort_field else : sort_name = 'name' if sort_name . startswith ( '!' ) : sort_name = sort_name [ 1 : ] sort_order = 'desc' else : sort_order = 'asc' for fieldname in column_names : fieldorder = 'none' if ( fieldname == sort_name ) : fieldorder = sort_order dataset . append ( [ fieldname , fieldorder ] ) return dataset
format items retrieved from xmlrpc for rendering by the generic_edit template .