Thank you for sharing this with us. Robin is our resident expert on GAE. Perhaps this can me incorporated into the next version.
Massimo On Feb 17, 9:59 am, CanPeaceLive <[email protected]> wrote: > Hello , > I've done a couple of patches to use SearchableModel in app engine I > would like to ask for feedback, I'm totally new to all app engine > python and web2py. > Features: > - Specify if a table is searchable (like the migrate argument) with > searchable=True > - Specify which properties are searchable or not > - Use search='searchString' argument in select queries > > To achieve these first I've modified the appengine SearchableModel to > take unsearchable_properties[] argument so it only indexes specified > items, this is useful because app engine indexes things which may not > be necessary. I got the idea from > here:http://www.billkatz.com/2008/8/A-SearchableModel-for-App-Engine > > Next I modified gql.py to import this new SearchableModel. And look > for searchable=True key in SQLTable._create : > I put **args in __init__ arguments and provided self.args = > args , then : > > if 'searchable' in self.args and self.args['searchable'] == True : > logging.info('search model called') > if 'unsearchable_properties' in self.args : > myfields['unsearchable_properties'] = self.args > ['unsearchable_properties'] > self._tableobj = classobj(self._tablename, > (search.SearchableModel, ), > myfields) > else: > logging.info('regular model called') > self._tableobj = classobj(self._tablename, > (google_db.Model, ), > myfields) > > (by the way python says classobj is deprecated) > > After that to use search='searchString' in database calls: > added 'search' in valid_attributes for SQLSet._select then : > > if 'search' in attributes.keys(): > items = search.SearchableModel.Query(table) > items = items.search(attributes['search']) > else: > items = google_db.Query(table) > > It seems to work pretty, I have not fully tested it, but I hope I'm > in right track, it is totally backwards compatible, just not > compatible with other databases in parallel. And be warned app engine > has bugs related to indexing non-ascii text... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" 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/web2py?hl=en -~----------~----~----~----~------~----~------~--~---

