sub controllers in Pylons

31 views
Skip to first unread message

writes_on

unread,
Mar 30, 2010, 4:03:01 PM3/30/10
to pylons-...@googlegroups.com

Hi all,

I'd like to create a sub-directory under controllers to help segregate
controllers in my application, and I see that paster can do this by issuing
this command:

paster controller {directory_name}/{controller_name}

where {directory_name} is the name of the sub-directory and
{controller_name} is the name of the new controller. I'm confused how to
construct a url to use this controller and place it in the routes.py file.

Can someone help me out?

Thanks!
Doug

--
View this message in context: http://n2.nabble.com/sub-controllers-in-Pylons-tp4826902p4826902.html
Sent from the pylons-discuss mailing list archive at Nabble.com.

Mike Orr

unread,
Mar 30, 2010, 4:47:07 PM3/30/10
to pylons-...@googlegroups.com
On Tue, Mar 30, 2010 at 1:03 PM, writes_on <doug.f...@gmail.com> wrote:
>
> Hi all,
>
> I'd like to create a sub-directory under controllers to help segregate
> controllers in my application, and I see that paster can do this by issuing
> this command:
>
> paster controller {directory_name}/{controller_name}
>
> where {directory_name} is the name of the sub-directory and
> {controller_name} is the name of the new controller. I'm confused how to
> construct a url to use this controller and place it in the routes.py file.
>
> Can someone help me out?

``map.connect(..., controller="directory_name/controller_name")``

If you want 'controller' to be a path variable, you'd have to write a
requirement regex that matches "identifier/identifier" with exactly
one slash and an identifier on both sides.

Don't forget .__init__.py in the subpackage.

--
Mike Orr <slugg...@gmail.com>

keybi

unread,
Mar 30, 2010, 4:43:06 PM3/30/10
to pylons-discuss
map.connect('/directory/controller/index/{some_id}',
controller='directory/controller', action='index')

Then you create urls like :

url(controller='directory/controller/', action='index',
some_id=1)

writeson

unread,
Mar 30, 2010, 5:27:09 PM3/30/10
to pylons-discuss
Thanks everyone, much obliged for her help! And fast too!
Reply all
Reply to author
Forward
0 new messages