On Wed, Aug 22, 2012 at 8:31 PM, Fang Zhou <[email protected]> wrote:
> Hi all,
>
> I have many controller like
>
> GameController
> CardController
> PlayerController
>
> and I want to build a dynamic url pattern like
>
> ("/%s/*", "%sController")
>
> Does Web.py provide this kind of url pattern? Or I need to write a central
> controller to dispatch the actions by myself?
I think you need to write one your self. It is not that hard.
urls = ("/(.*)/(.*)", "dispatch")
class dispatch:
def GET(self, name, path):
cls = globals().get(name + "Controller")
method = web.ctx.method.upper()
return getattr(cls(), method)(path)
POST = GET
You may have to take care of handling AttributeException and raising
NoMethod etc.
Anand
--
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en.