On Wednesday 29 July 2009 11:59:55 adam wrote:
> what do you mean Diez??
something like
clauses = []
for word in words:
for field in fields:
clauses.append(or_(field.like("%%%s%%" % word)))
Depending on what you actually searching for, and_ might also be used.
>
> On Jul 28, 11:29 am, "Diez B. Roggisch" <[email protected]> wrote:
> > On Tuesday 28 July 2009 12:01:06 adam wrote:
> > > i have now added in a for loop that splits the search sting down into
> > > seperate word
> > >
> > > word = info
> > > words = word.split()
> > > results = []
> > >
> > > for w in words:
> > > search_string = "%%%s%%" % str(w)
> > > clause = []
> > > abc = AddressBookContact
> > > for column in (abc.contact_surname,
> > > abc.contact_email,abc.contact_forename,abc.contact_address1,abc.contact
> > >_add ress2,
> > >
> > > abc.contact_street,abc.contact_town,abc.contact_county,abc.contact_post
> > >code ,abc.contact_country,abc.contact_telephone, abc.contact_mobile):
> > > clause.append(column.like(search_string))
> > > forename = DBSession.query(AddressBookContact).filter
> > > (or_(*clause))
> > > results.append(forename)
> > >
> > > i have searched the list for repeating users and removed them. Is this
> > > more efficient?
> >
> > I think it's better to combine the search-fields with or to *one*
> > SQL-statement. Otherwise, you won't get global ordering.
> >
> > Diez
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---