redirect() works by raising an HTTP exception, so I think the redirect in 
your try is triggering your except, so it ends up flashing the response body 
of the redirect. Why are you catching HTTP exceptions -- is anything in your 
try likely to trigger an HTTP?

Anthony

On Monday, October 10, 2011 8:11:04 AM UTC-4, Ross Peoples wrote:
>
> Sorry it took so long to get back. Been a crazy couple of days:
>
> This is my controller:
>
> @auth.requires_login()
> def index():
>     form = SQLFORM.factory(
>         Field('partnumber', length=30, requires=IS_NOT_EMPTY()),
>         Field('quantity', 'double', default=1, 
> requires=IS_FLOAT_IN_RANGE(0.1, 1000000, error_message='Quantity must be 
> greater than 0')),
>         Field('required_date', 'date', requires=IS_NOT_EMPTY()),
>         Field('drawing', 'upload', uploadfolder=drawing_folder),
>         table_name = 'rfq_item'
>     )
>     
>     if form.accepts(request):
>         try:
>             add_partnumber(form.vars.partnumber, form.vars.quantity, 
> form.vars.required_date, form.vars.drawing)
>             form.vars = Storage()
>             session.flash = 'Part added'
>             redirect(URL('index'))
>         except HTTP as e:
>             response.flash = e.body
>     elif form.errors:
>         output = ''
>         for k, v in form.errors.items():
>             output += '%s: %s\n' % (k, v)
>             
>         response.flash = output
>     
>     query = db.batch.auth_user==auth.user.id
>     toolbar = '<a href="#" class="button suppliers">Suppliers</a><a 
> href="#" class="button create_rfq">Create RFQ</a>'
>     table = plugin_datatable(query, selectable=True, deletable=True, 
> updatable=True, toolbar=toolbar)
>     
>     response.title = 'New RFQ'
>     
>     return dict(form=form, table=table)
>
>
> Basically, I have a view with a data table, and a form to add another item 
> to the table. When the form is submitted, it adds the item, then has to do a 
> redirect to itself to avoid the "confirm form resubmission" message when the 
> page is refreshed after submitting the form.
>

Reply via email to