Perhaps you want to use static methods:
class Test(object):
@staticmethod
def get(row):
return row.name
Anthony
On Saturday, August 25, 2012 11:33:06 AM UTC-4, Marek Mollin wrote:
>
> Hello,
>
> I have a problem with a construct like that:
> db.define_table('test',
> Field('name'),
> )
>
>
> class Test(object):
> def get(row):
> return row.name
> def get_hello(row, greeting):
> return '%s %s' % (greeting, row.name)
>
>
> db.test.get = Field.Lazy(Test.get)
> db.test.get_hello = Field.Lazy(Test.get_hello)
>
> Why it would not work ?
> It works perfect if its a standard function. But if its unbound method I
> get TypeError expected at least 1.
>
> I am trying to do that in order to better organize models, I do not want
> to go as far as Bruno's modelless aproach as performance is not the issue
> but overtime they become messy. (Also I know that I can just make seperate
> file, but then I have to add number to the file and again it becomes very
> unclean).
>
> The whole deal is to move at least some of the logic to those Lazy fields
> (its a pain to have fat controllers).
>
--