Anthony, that sounds nice, but I have 2 considerations. 1) Sometimes we need to make more than fits in a lambda, i.e, work on more complex filtering, validate input args, etc. 2) When using a visual tool to generate models (aka, WWWSqlDesigner), decoupling it from define_table() is a plus.
I don't want to raise a flame, but models not being declared as classes brings some pros and cons. Long live to monkey patching. ;-) Note, I don't see the need to incorporate this to the framework, as Python allows us to do it. I'll post the @make_member_of() decorator in web2pyslices. On Thu, May 2, 2013 at 11:53 AM, Anthony <[email protected]> wrote: > Just brainstorming here...how about an API more like this: > > On the other hand, you could also just do: > > db.person.just_males = lambda: db(db.person.gender == 'm').select() > > Maybe we could allow db.define_table() to accept arbitrary keyword arguments > so these can be defined and still keep the table lazy: > > db.define_table('person', ..., just_males=lambda: ...) > > Anthony > > On Wednesday, May 1, 2013 5:34:48 PM UTC-4, viniciusban wrote: >> >> I created a decorator to allow binding a function to a Table instance. >> >> IMHO, this helps organizing models, creating something similar to >> Django's managers. >> >> To an example, see: https://gist.github.com/viniciusban/5497532 >> >> To get an scaffolding application with organized model files and this >> decorator embedded, visit https://github.com/viniciusban/my_welcome >> >> Hope this helps somebody. >> >> Massimo, what do you think about embedding this decorator (or >> something better) in web2py, to allow creating table methods? >> >> -- >> Vinicius Assef > > -- > > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.

