Arguments

13 views
Skip to first unread message

MattRock

unread,
Jan 25, 2012, 6:10:53 PM1/25/12
to turbo...@googlegroups.com
This may be a silly question, but I am curious about passing arguments in the URL. I have a controller called "controller."  I pass an argument to the controller in the URL by pasing the URL as "/controller?argument". I would like to pass the argument Pyramid style as "/controller/argument."

Is this possible to do with TG2?  Can this be done and still have additional defined actions in the BaseController [I.E. /controller/action]? 

I know I could probably do this with rewrite, but I would like to keep this in the application if possible.

Any assistance is appreciated.

Thanks,
MattRock

Alessandro Molina

unread,
Jan 26, 2012, 4:32:37 AM1/26/12
to turbo...@googlegroups.com
On Thu, Jan 26, 2012 at 12:10 AM, MattRock <matt.r...@gmail.com> wrote:
> This may be a silly question, but I am curious about passing arguments in
> the URL. I have a controller called "controller."  I pass an argument to the
> controller in the URL by pasing the URL as "/controller?argument". I would
> like to pass the argument Pyramid style as "/controller/argument."
>
> Is this possible to do with TG2?  Can this be done and still have additional
> defined actions in the BaseController [I.E. /controller/action]?
>

Each argument found after the first found exposed method is treated as
an argument to the method itself.
So you can write /controller/arg1v/arg2v/arg3v instead of
/controller?arg1=arg1v&arg2=arg2v&arg3=arg3v the two are equivalent.

Just pay attention to the index method.
When called as /index/1/2/3 everything works, but to achieve /1/2/3
you will need to use _default instead of index.

MattRock

unread,
Jan 26, 2012, 5:57:32 PM1/26/12
to turbo...@googlegroups.com
Exactly the information I was seeking, thank you. It works as desired.
Reply all
Reply to author
Forward
0 new messages