contains and startwith do not work on GAE because they do not support
it. I am looking into possible workaround. Instead of this:

pages =
db(db.plugin_wiki_page.id>0).select(db.plugin_wiki_page.slug)
            for page in pages:
                if page.slug.find(string) > -1:
                    found.add(page.slug)

you can do this

found =
db(db.plugin_wiki_page.id>0).select(db.plugin_wiki_page.slug).find(lambda
r: r.slug.find(string)>=0)



On Jul 27, 10:34 pm, Bruno Rocha <rochacbr...@gmail.com> wrote:
> I Solved my problem in a hard way with a custom widget, the only way I found
> to perform %LIKE% on GAE
>
> @staticmethod
>     def searchPages(string=None,nfmessage='Nothing found with %s'):
>         """
>         string: string to be found
>         """
>         found = set()
>         if string:
>             #search in slug
>             pages =
> db(db.plugin_wiki_page.id>0).select(db.plugin_wiki_page.slug)
>             for page in pages:
>                 if page.slug.find(string) > -1:
>                     found.add(page.slug)
>
>         if found:
>             return UL(*[LI(row) for row in found])
>         else:
>             return nfmessage % string
>
> 2010/7/28 Bruno Rocha <rochacbr...@gmail.com>
>
>
>
> > Also fails on JQGRID Search,
> > I Know GAE has some limitations performing LIKE, so I think if this have no
> > solution, may be disabled when running in GAE.
>
> > 2010/7/28 Bruno Rocha <rochacbr...@gmail.com>
>
> > Hi,
>
> >> trying to use the search widget on GAE i got an error,
>
> >> ``
> >> name: search
> >> table: plugin_wiki_page
> >> ``:widget
>
> >> Only EQUALS and NOT EQUALS runs ok, when I try CONTAINS, STARTSWITH or
> >> ENDSWITH I got the error:
>
> >> YOU CAN TRY HERE:
> >>http://web2pybrasil.appspot.com/cursoweb2py/plugin_wiki/page/error-on...
>
> >> THE ERROR:
> >> Traceback (most recent call last): File
> >> "/base/data/home/apps/web2pybrasil/3.343537232039186008/applications/cursoweb2py/models/plugin_wiki.py",
> >> line 555, in render_widget html = getattr(PluginWikiWidgets,name)(**args)
> >> File
> >> "/base/data/home/apps/web2pybrasil/3.343537232039186008/applications/cursoweb2py/models/plugin_wiki.py",
> >> line 226, in search search, results = crud.search(db[table]) File
> >> "/base/data/home/apps/web2pybrasil/3.343537232039186008/gluon/tools.py",
> >> line 2979, in search query &= self.get_query(field, opval, value) File
> >> "/base/data/home/apps/web2pybrasil/3.343537232039186008/gluon/contrib/gql.py",
> >> line 569, in __and__ if other.filters[0].one(): AttributeError: 'Query'
> >> object has no attribute 'filters'
>
> >> --
>
> >>http://rochacbruno.com.br
>
> > --
>
> >http://rochacbruno.com.br
>
> --
>
> http://rochacbruno.com.br

Reply via email to