le 07.04.2009 00:49 chris_g a écrit: > > On Apr 6, 4:50 pm, Remi Jolin - SysGroup <[email protected]> > wrote: > > >> When you are rendering an existing data set, do you pass only the id or >> use kw ? >> >> If there are no kw params, you should not go through the if kw: part and >> render the form... But if you use kw you will trigger the >> get_errors(...) and eventually render the form too with tg_errors added >> to the return dict. >> >> Are you sure the issue is not in your form definition or the "params" >> you pass when in the last "else: # no data posted..." I would look there >> first. >> > > Remi, > > Thanks for looking at this. > > Just to clarify: > > When I render an existing data set, by using a GET, there are no kw > params, but there is an 'id' argument. > > http://localhost:18082/order/?id=315 > > OrderController.index id=u'315', tg_errors=None, kw={} > > This all works without a problem. > > When I modify this data set it is posted to; > http://localhost:18082/order > > > OrderController.index id='', tg_errors=None, kw={ > 'wo_form_key': u'4.1239057259.0', 'custom_number': u'ORD002000129', > 'plu_classes': [ > {'order_lines': [{'plu_code': u'8001', 'qty_supplied': u'12', > 'qty_ordered': u'12'}, > {'plu_code': u'8002', 'qty_supplied': u'12', 'qty_ordered': u'12'}, > {'plu_code': u'8003', 'qty_supplied': u'3', 'qty_ordered': u'3'}]}], > 'store_id': u'2', 'order_id': u'315', 'action': u'open', > 'custom_number_invoice': u'INV002000129', 'order_submit': u'Open > Order'} > > Note that this process works when there are no validation errors. > > Actually, I am getting the internal error from the params generated in > the conditional block where "Errors were encountered". > > I fully expect there to be problems with the params here. They should > contain invalid data. I want invalid data to be displayed to the user, > so it can be corrected. > > The problem is that I am unable to display this data because the > validator causes an exception to be thrown before the form is > rendered. > What I would to is have a look to tg_error after the call to get_errors to see which validator "failed" on which field of your form. Then have a look to the form, especially if you have a specific template (may be a HTML syntax, when rendering error messages for specific field(s)).
The error message you provided looks like the form rendering tries to evaluate "Please enter an integer value". Is it a message coming directly from a validator or is it coded in your template ? If so it could be something like <div py:if="error" py:content="Please enter...." />. This will lead to an error (only if "error") and should be written as <div py:if="error" py:content="'Please enter....'" />. > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

