ToscaWidgets Pylons sample: initial http request fails

0 views
Skip to first unread message

Bill

unread,
Dec 20, 2006, 1:48:39 PM12/20/06
to TurboGears Trunk
I've been experimenting with the Pylons ToscaWidgets (TW) sample with
Pylons 0.9.3. Other than for fixing a couple of references in
lib/base.py and lib/helpers.py the sample runs fine except for one
strange problem. After I run paste and go to the URL for the sample in
my browser I get the exception shown below. But when I refresh my
browser the form works fine. Here is the exception from the initial
http request :

Error(TypeError): object does not support item assignment

/usr/lib/python2.4/site-packages/ToscaWidgetsForms-0.1a0dev_r2217-py2.4.egg/toscawidgets/forms/fields.py
line 240

237:
238: def update_params(self, d):
239: super(Form, self).update_params(d)
240: d['value']['_submit'] = d['submit_text'] <<HERE
241:

The debugger shows me that the value of d['value'] is None. Looking
further back into TW's Widget class definition, the prepare_dict method
has this code:

/usr/lib/python2.4/site-packages/ToscaWidgets-0.1a0dev_r2235-py2.4.egg/toscawidgets/core.py

416 if value is None:
417 value = self.default
418 value = d['value'] = self.adapt_value(value)

Using the debugger again I see that the value of 'value' at line 416 is
an empty string. Since the expression (value is None) is False the null
string passes through to line 418. In turn, the debugger shows the
return value of self.adapt_value(value) to be None when value is an
empty string. So of course d['value'] can't subsequently be indexed
since it is not a dict. Forcing value, in this case, to be an empty
dict eliminates the exception.

Hopefully this analysis is of some help.

Cheers,
Bill

Bill

unread,
Dec 21, 2006, 3:55:39 PM12/21/06
to TurboGears Trunk
Hi All,

On Dec 20, 10:48 am, "Bill" <wtren...@gmail.com> wrote:
> I've been experimenting with the Pylons ToscaWidgets (TW) sample with

<snip>

A bit of confusion here. I originally posted this on the
pylons-discuss group but it didn't show up for hours so I thought
something was wrong. I decided to then post here to see if it would
get through to Alberto one way or another. Well, a day later my
original post shows up on pylons-discuss and Alberto has addressed it
there. I didn't realize the posts on Google Groups take so long to
arrive.

Sorry for the confusion,
Bill

Kevin Dangoor

unread,
Dec 23, 2006, 4:07:35 PM12/23/06
to turbogea...@googlegroups.com
On Dec 21, 2006, at 3:55 PM, Bill wrote:

> A bit of confusion here. I originally posted this on the
> pylons-discuss group but it didn't show up for hours so I thought
> something was wrong. I decided to then post here to see if it would
> get through to Alberto one way or another. Well, a day later my
> original post shows up on pylons-discuss and Alberto has addressed it
> there. I didn't realize the posts on Google Groups take so long to
> arrive.

I wouldn't be surprised if Ben has the pylons list set up the same
way the TG lists are: new members are moderated. It prevents spam
from making it through.

Kevin

Reply all
Reply to author
Forward
0 new messages