On 1/12/06, Max Ischenko <[EMAIL PROTECTED]> wrote:
> OK, so the question is: is it possible to use the same method to both
> show input form and process data? If yes, how'd I do it correctly?
It's possible using the change you made to controllers.py. What Kevin
is saying is that the change you've made depends on knowledge of your
application.
For example say you have the following function mounted on the root
(so /foobar gets you to here):
@expose(inputform=some_form, template=".show_form")
def foobar(self,*args,**params):
return dict(args = args, params = params)
And that the form in show_form has method POST and action '/foobar'.
If you make the changes you've made to controllers.py, it will work
like you expect as long as the query string portion of your url is
empty (no GET parameters). If you try to access it using
'/foobar?tg_format=json' because you're doing ajax requests, it should
still work because tg_format and tg_random are stripped before they
get to the validator. If you have anything else, like
'/foobar?action=edit', you'll get weird behavior because TG will try
to process the get params as if it's the values from inputform.
Passing inputform tells Turbogears that you want the params treated as
if they were that form. It makes no distinction between GET and POST
forms and only your app can know if there's a meaningful difference
between the two. It may be possible to separate GET from POST by
mucking around with cherrypy but you'll have to write your own version
of turbogears.expose.
Hopefully that makes sense.