Perhaps:
session.search_term = search_form.vars
should be:
session.search_term = search_form.vars.Search
Anthony
On Wednesday, July 25, 2012 8:55:39 AM UTC-4, Alec Taylor wrote:
>
> Thanks for that, that solved the error, however a strange result is now
> occurring, always None; even when using the exact name is specified:
>
> def search():
> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
>
> search_result=None
> if search_form.process().accepted:
> session.search_term = search_form.vars
> query = ( db.group_of_events.group_name.contains(session.search_term)
> | db.group_of_events.group_desc.contains(session.search_term) |
> db.group_of_events.group_tags.contains(session.search_term) )
> search_result = db(query).select()
>
> return dict(search_form=search_form, search_result=search_result)
>
>
> Note: I've confirmed that it's received the correct term by returning `
> search_result=session.search_term`.
>
> Did I misrepresent the query?
>
> On Wednesday, July 25, 2012 9:52:00 PM UTC+10, Johann Spies wrote:
>>
>> On 25 July 2012 13:38, Alec Taylor <[email protected]> wrote:
>>
>>> Unsure as to why this isn't working, it looks the same as the examples
>>> in the DAL chapter:
>>>
>>> search_form = SQLFORM.factory(Field('Search', requires=IS_ALPHANUMERIC()))
>>> if search_form.process().accepted:
>>> session.search_term = search_form.vars.search_term
>>> #query = (
>>> db.group_of_events.group_name.contains(session.search_term) |
>>> db.group_of_events.group_desc.contains(session.search_term) |
>>> db.group_of_events.group_tags.contains(session.search_term) )
>>> rows =
>>> db(db.group_of_events.group_name.contains(session.search_term)).select()
>>> return dict(search_terms=rows)
>>>
>>>
>>> I'm getting a:
>>> <type 'exceptions.TypeError'> CONTAINS() takes exactly 3 arguments (2
>>> given)
>>>
>>> What am I doing wrong?
>>>
>>>
>> Where does search_form.form.vars.search_term come from? You defined a
>> field with a name 'Search', not 'search_term' .
>>
>> Regards
>> Johann
>>
>> --
>> Because experiencing your loyal love is better than life itself,
>> my lips will praise you. (Psalm 63:3)
>>
>>
--