I've been playing 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 an exception:
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 value at line 416 is an empty string. Thus (value is None) is False and 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 None. Forcing value, in this case, to be an empty dict eliminates the exception. Now for the 'strange' part. If I simply click on my browser's refresh button (ie, a 2nd GET), the form pops up. I can fill it in, submit it, the validation works, and I can do this repeatedly. So it is only on that first GET after launching the app that the exception happens. Seems like an initialization problem. Anyway, I'll have to leave the solution to the TW developer. Hopefully this analysis is of some help. Cheers, Bill --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
