Jorge Godoy wrote:
> > There is a real lack of explanation on how to perform basic
> > tasks, it seems. There's lots on SQLObject but I'm not interested in
> > that at the moment unfortunately.
>
> You can use the 20 minute wiki notes for that.  It is targeted towards 0.8.

Unfortunately lots of those notes are also about handling SQLObject
stuff and not enough about checking form submissions and the like. The
only use of a validator appears to be a pretty bizarre usage aimed at
making an if statement shorter! Surely people are more bothered about
checking values are within acceptable ranges or that a phone number
contains the right number of digits than they are about having to use
"if blah==None" instead of "if blah"! The docs drive me mad!

> To me, showing and submitting is different.  What do you do while editing
> data?  I submit data and come back to the same edition page, with the new data
> entered, of course.

But between showing the original form, and showing the altered data,
you don't normally want to show an intermediate page, do you? So it
makes sense not to have that intermediate page or method.

I want to have pseudocode like this:

    # Page 1
    if form has been submitted:
        if submitted values are ok:
            perform database modification/whatever action
            redirect to Page 2
        else:
            generate error strings
    display error strings, if they exist
    display form, which submits to itself, with inline form data if it
exists

http://www.livejournal.com/login.bml is one good example of how this
should appear to the user.

Now, I appreciate that this is a method that is the best for ASP and
PHP where the template and the logic are in the same file, and that it
may not be the best way for TurboGears. However, I don't see a /simple/
way of replacing this functionality. These are my requirements:

  - I want the same URL in the address bar both when it's the first
time you visit the page and see an empty form, or when you've already
submitted data and are returned to the page (perhaps because some of
the data was wrong)
  - I want the form to be populated with the previously entered data,
if it exists (eg. if they entered a valid address but an invalid
telephone number, I want to keep the address). Obviously the form still
has to work if that data isn't provided yet (ie. on the first visit).
  - I don't want the user to ever see an intermediate 'redirecting'
page or anything like that
  - The code should be shorter than the PHP equivalent (or there's no
point me using TurboGears)

These seem like obvious requirements for any login system or ordering
system where you enter a shipping address, but I am having trouble
finding clear examples of how to do it.

I don't need separate save/update/delete functionality and trying to
understand that in the example just confused matters for me. I'm not
doing database manipulation, just web form handling. I only have 1
thing to do with this form - submit it. It either succeeds and moves to
the next page, or it doesn't and it stays on this page for the user to
try again. It should be simple. It probably /is/ simple, but TurboGears
isn't telling me how.

Sadly I'm wasting multiple hours on this when it would have taken less
than one hour in PHP :(  If I can't get this working soon without
spending way too much time on trial and error then I will give up and
use something better documented instead.

-- 
Ben Sizer


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to