Ah. So that explains why I didnt see a http request for re-generating
the form....!.

Javascript will also work perhaps. My App already requires javascript
anyhow.  So javascript dependence is already a given and  really is
not an issue.

I went with the other option though.

So when validation fails I am generating a dict with appropriate
values and rendering the template - passing htmlfill this dict + the
templates html  + the errors to redisplay the form. I am however also
computing a list of tuples for the dynamic select fields  and passing
this list in the c context for use in populating select field options.

Thanks for taking the time to assist me in exploring all the
possibilities....

On Jun 30, 3:01 pm, Mike Orr <[email protected]> wrote:
> On Jun 29, 12:18 pm, afrotypa <[email protected]> wrote:
>
> > I ran through the scenario again and did not see a 2nd http get to
> > 'edit' upon validation failure. I can verify that 'edit' was indeed
> > called though.
>
> See lines 160-161 in pylons/decorators/__init__.py:
>
>             request.environ['pylons.routes_dict']['action'] = form
>             response = self._dispatch_call()
>
> This replaces the original action returned by Routes, with the one
> specified in the ``form`` argument.  It then calls
> pylons.controllers.core.WSGIController._dispatch_call() [inherited
> from your base controller], which calls the other action as Pylons
> normally would.  All without another HTTP request.
>
> If you do write alternate code to redisplay the form, you'd generate
> the form into a variable (or render the page template if that's how
> you'd normally do it), create a dict with the proper fill values
> (based on request.params; probably not on self.form_result because the
> validation failed), and then call htmlfill and return the result.
>
> I also wonder if Javascript might be appropriate since you're
> modifying one form control based on another.  This does mean the form
> won't function properly if Javascript is disabled, but that may be
> acceptable in the circumstance.  Then the form display would only have
> to pre-set the base control, and let the Javascript set the derived
> control.
>
> --Mike
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to