Jorge Godoy wrote:
> "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:

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

That's because it has 2 methods for submission - one using Javascript
if it's available and one using a normal POST otherwise. The code
itself is not as important as the fact that it submits the data to
itself like many web apps do.

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

Yes, unfortunately 'take action' seems a little complicated when I need
to pass various POSTed arguments back and forth across methods. With
the 'submit to self' option it's trivial because all your data is in
POST variables - you handle it accordingly and either redirect if
successful or use those variables to fill in the form if you need to
show it again.

On the other hand, if I submit to a different URL/method, that page
will receive the POST variables - all good - but in the event of error,
I then have to redirect back to the original page, and pass in 2 sets
of data, ie. the POSTed variables plus the set of errors to display.
Assuming this method is still better than the previous one when using
TurboGears, what is the cleanest way of doing this? I have seen no
directly relevant examples in the 20m Wiki or the Getting Started
guide. Perhaps I missed one?

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

How do I send that data back? I assume I'm going to have to use a
redirect but how do I form that appropriately, and in a way such that
the original page will work properly in the absence of that data (ie.
on the first view)?

(I don't think it's any coincidence that when I just put "cherrypy
redirect" into Google to try and answer this for myself, the first
result was <http://lion.taoriver.net/?p=10> highlighting pretty much
the same problems as I'm having.)

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

I don't particularly like PHP either but if you need to know how to do
something, the docs tell you. When it comes to maintenance and pleasure
in writing code, PHP lets me put down ugly but working code in 10
minutes, because I can find examples in their docs, whereas TurboGears
seems to make me wait weeks for the pretty and well-maintained code
because I can't find any example of what I want to do.

Believe me though, I wouldn't be bothering with this if I actually
liked PHP.

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

I really have gone through both the Wiki and the Getting Started guide.
The problem is, pretty much as Lion Kimbro said on the blog, when I try
to do something a little different to what is detailed on the
walkthroughs, you find that there's nothing telling you how to do it.

Thanks again for your help,

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