Well, the attrwrapper uses getattr to get the value for the field, and
therefore accepts strings instead of the attribute itself.
For instance
DataGrid(fields=[("prettyname","classattr")]).display(value=ModelClassInstance)
works. That is also what the docs show you. I did not know that doing
DataGird(fields=[("prettyname",ModelClass.classattr)]).display(value=ModelClassInstance)
would also work. Thanks for the tip. I'll try it.
Dolf.
On Feb 17, 11:43 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> SmokeyD schrieb:
>
> > Diez,
>
> > I don't understand completely. When I pass a ModelClass.method as the
> > getter in a tuple of the fields property, the method is not called but
> > just "<instance method.....>" or something similar is returned. That
> > was the whole point of my code, to allow the passing of a
> > ModelClass.Method as the second entry in the tuples of the fields
> > list.
> > I found (but maybe I did something wrong) that
> > DataGrid(fields=[('prettyname','ModelClass.method')]) does not result
> > in ModelClass.method being called to retrieve the value for the
> > 'prettyname' column for each row. Am I mistaken?
>
> You are. Because "Class.foo" is always a string, but when you want to
> pass a callable, you do
>
> Class.foo
>
> Note the missing quotes.
>
> Go to the interpreter and type
>
> >>> def foo(): pass
> ...
> >>> foo
> <function foo at ...>
>
> Do that for a class-method as well.
>
> Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---