Debugging the TextField widget "<built-in method title of str object at 0xb7b416a0>" bug

1,902 views
Skip to first unread message

Mike Kent

unread,
Jan 21, 2006, 8:02:34 PM1/21/06
to TurboGears
I decided to take a crack at one of the current bugs, where a TextField
widget named 'title' would display on a form with the text '<built-in
method title of str object at 0xb7b416a0>' filled in. Trac is down, so
I don't know what the Trac bug number this is, but it does have a
number.

You can see this bug by putting the following in a controller:

myForm = TableForm(widgets=[TextField('title')])

and then passing that to a template via the returned dict, then
inserting the form in the template.

It became obvious pretty quickly that something in TG was doing the
equivalent of 'repr(getattr('some string', 'title')), and putting it
into the value displayed in the field. In fact, changing 'title' to
'upper' resulted in '<built-in method upper of str object at
0xb7b416a0>'. However, changing 'title' to 'foobar' results in an
empty field, which lead me to believe the code was doing the equivalent
of 'repr(getattr('some string', 'foobar', ''))' or possibly
'repr(getattr('some string', 'foobar', None))'.

After spending some time with the code, I found the following in the
template for the TableForm widget (line 138 widgets/forms.py):

<td>${widget.insert(getattr(self.widget_value, widget.name, None),
input_values, widget_error.get(widget.name, None))}</td>

After some study, I've determined that the intent of this code is to
pass the current value of a widget on the form (in this case, a
TextField widget) to the insert method of that widget. Changing the
first argument of the above insert call to None results in an empty
field being displayed rather than the '<build-in method...' text, but
obviously if the TextField widget has a value, it will not be
displayed. I can change the first argument to widget.default, and get
the default value of the widget displayed in the field, but I'm not
sure this exactly fills the intent of the code.

At this point, I suppose Kevin will need to take a look at this code
and determine what the actual intent is before a patch can be generated.

Mike Kent

unread,
Jan 22, 2006, 10:08:44 AM1/22/06
to TurboGears
OK, Trac is back up this morning, so I added a reference to the above
message to Trac bug # 272.

Christoph Zwerschke

unread,
Jul 1, 2012, 2:36:07 PM7/1/12
to turbo...@googlegroups.com
Am 30.06.2012 21:12, schrieb JustOnce:
> THAT error in python is if you miss a "()" at the end of a function
> name. For example, if str is an object and str.upper() is a method, you
> will get this error if you call str.upper instead of the expected
> str.upper()
>
> If I get this error, all I do is add the brackets correctly, and of
> course I pass the right parameters. The errir for parameters will be
> thrown only if the brackets are there in the first place...
>
> On Sunday, January 22, 2006 6:32:34 AM UTC+5:30, Mike Kent wrote:
>
> I decided to take a crack at one of the current bugs, ...

Why do you give such a superficial response of no avail and with top
posting to a bug report that is over six years old and has long been
closed? Please observe the conventional netiquette when posting.

-- Chris
Reply all
Reply to author
Forward
0 new messages