Jorge Godoy wrote: > "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes:
> Yep. And it's not different with two methods or just one... You'll have to > do the same things. Using two methods makes them smaller -- they are > specialized in doing one part of the whole thing -- and more readable than if > you have to consider what value comes in for X variable if it is a submit or > if it is not, then what should happen on each and every condition where this > form can be reached... Using two methods, one will always have data submitted > to it and the other won't. But the template is going to need those variables no matter which of the 2 methods I call. So both methods are going to need to provide them in some form, even if one of the 2 methods just makes them empty or None or whatever. In this case I'd think it makes sense to use a default argument to represent the empty variables, which in turn suggests the use of just one method. No? > > 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 believe that I already answered that when I gave you some examples and even > skeleton code. That is my opinion... You did show how to use cherrypy.HTTPRedirect to redirect but I don't know how to use that (and presumably turbogears.url) to pass POSTed variables, and/or an arbitrary dictionary of errors. I can't find turbogears.url in the docs. > > 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)? > > When you submit your form, your variables can be grouped in a dictionary. > That is what I showed you with the **kword feature. I know how the variables arrive from a form submit action, but I meant when I do the redirect. Redirects don't typically send POST data so how do I send that information back to the form page? Do I have to use GET? Or do I have to call the method directly? > The same happens for web forms, but the keywords are the names you use as > "name" attribute and the value is the value they have. Even after a HTTP redirect back from the data processing page to the original form-display page? > > (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.) > > Since you're using TurboGears and not cherrypy directly, I'd say you'd better > try solving it with TurboGears instead of low level cherrypy... You'll have > less problems. But if the code line I'm supposed to use reads 'cherrypy.HTTPRedirect', and the TurboGears API docs don't have an entry for 'HTTPRedirect', then what else am I supposed to do? > Anyway, look for the post he said he had in his Emacs buffer where he stated a > different opinion. You can search for it at this list archives. I read that, and can only assume someone answered his questions in a day. Unfortunately, despite the best efforts of yourself and Simon, my questions haven't been answered in a week. I still am not sure of a good way to get data back from the processing method to the form-displaying method. I posted some sample (pseudo)code showing how I will try to do it when I next get a chance, but it's not been commented on, so I don't know if it will work or not. > > 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. > > You're lucky... Or I am. I had the opposite feeling. Specially with > reinventing the wheel many times in PHP... I like working alone and looking up how to do things in reference material. That's why PHP has worked for me. I also taught myself Python by reading through the reference and doing projects on my own. That's why I'm surprised that this is not possible with TurboGears. Or perhaps it is possible, if I wanted to read through all the source code. PHP is just an example though. I could have coded this application in ASP too, or a cgi script in C, in half the time it's taken me to experiment with TurboGears and post here. I am grateful for people being helpful here but it shouldn't have to be this way. > So, come here and ask! Tell what you did, what happened, what you expected to > happen, how you did things, etc. People are very helpful here. Well, this is my only thread about it, because I haven't achieved anything else to ask about because this issue is holding me back. Thanks, -- 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 -~----------~----~----~----~------~----~------~--~---

