"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

> 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

I don't.  And there's no intermediate page. :-)

> makes sense not to have that intermediate page or method.

I dunno.  The page never appears on my URL and solved the problem... 

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

It has a bunch of crappy code in the middle of the HTML code.  Lots of
validation and it looks like the user auth code is in JavaScript.  I prefer
having a clean HTML page with all my checks hidden from curious users.
Submitting to the same page is OK if you check for something before deciding.
I just don't think it is a nice design (to me...).

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

Check for some form filled value nd take actions based on that.  This is
simple. 

>   - 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).

Send a dictionary with data back to the template and use values present in it
all the time.  If there were no previous values, you'll choose either empty or
default values that you've sent.

>   - I don't want the user to ever see an intermediate 'redirecting'
> page or anything like that

So don't put it in your forms as action.  And always check values submitted. 

>   - The code should be shorter than the PHP equivalent (or there's no
> point me using TurboGears)

Here I can't help.  I think more of a maintenance and pleasure in writing code
than in code size.  My experience with PHP is not pleasant at all, so I avoid
it at all costs.  I prefer coding Perl than PHP.

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

If you use 0.9, there's identity that solves a lot of your problems.  It just
requires you to use a decorator for methods that should be protected and
that's 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.

The action is sent to the method named like it (e.g. <form name='my_form'
action='send_data'> will send your data to the python method 'send_data').

There you'll have to check for your fields (their names become variable
names). 

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

That's one of your choices.  The other is really repeating the wiki tutorial
-- it should take you one or two hours and you'd have a good understanding of
what's going on... 

-- 
Jorge Godoy      <[EMAIL PROTECTED]>

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