Question

In a previous question, I was trying to figure out the right strategy for to passing data between forms in Pyramid. Based on the answer I received, I decided the approach of using a hidden form.

I started implementing this and think there must be a better way of passing along the data. Specifically, passing parameters through the url results in a tuple that is messy to parse.

I want it to be general enough to not to know what parameters the form has and also it needs to handle file fields as well.

How I'm currently attempting to pass the form data to the confirmation page:

@view_config(renderer="templates/derived/load/error.mak", route_name='process_model_route')
def process_model(self):
    #processing logic and validaton, failiure in validation sends user to error.mak
    return HTTPFound(route_url('confirm_model_route', self.request, fparams=self.request.POST))

Route: config.add_route('confirm_model_route', 'rnd2/model/confirm/*fparams')

@view_config(renderer="templates/derived/confirm/model.mak", route_name='confirm_model_route')
def confirm_model(self):
    form_dict = self.request.matchdict['fparams']
     #need to decode and pass to template
     return dict({'load_route':load_route, 'form_dict':form_dict})

The confirm/model.mak template would contain the hidden form.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top