On Mon, Nov 04, 2013 at 10:43:52AM -0800, Stuart Zurcher wrote:
> class user(CrudRestControllerConfig):
> class table_type(TableBase):
> __entity__ = User
> __limit_fields__ = ['display_name', 'email_address']
> __url__ = '../user.json' #this just tidies up the URL a bit
>
> class table_filler_type(TableFiller):
> __entity__ = User
> __limit_fields__ = ['_id', 'display_name', 'email_address']
> value = table_filler_type.get_value(table_filler_type(DBSession),
> values={}, limit=20, offset=0, display_name='*SZURCHER')
I created a new filler_type class and then fooled around with the
do_get_provider_count_and_objs() That method calls extra_filters which
looks at the **kw for special fields and returns SQLAlchemy conditions.
So the way it works is:
User goes to /admin/blah?h=123
blah class has table_filler_type with changed inheritied class
do_get_provider_count_and_objs has kw={'h': 123}
extra_filters is called with that same kw
extra_filters knows 'h' is "special" and looks to see if the
given entity has a column called host_id (the "h"->host.id mapping is
fixed)
extra_filters returns [Blah.host_id==123]
do_get_provider_count_and_objs uses that as its conditions for the SQL
query
As I am using jquery grids and you can have double filtering (and it
works too) its a bit more complicated than that, but hopefully you
get the idea.
It's all found in gory detail in the jqQueryTableFiller at
https://github.com/csmall/rnms/blob/master/rnms/lib/table.py
- Craig
--
Craig Small VK2XLZ http://enc.com.au/ csmall at : enc.com.au
Debian GNU/Linux http://www.debian.org/ csmall at : debian.org
GPG fingerprint: 5D2F B320 B825 D939 04D2 0519 3938 F96B DF50 FEA5
--
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/turbogears.
For more options, visit https://groups.google.com/groups/opt_out.