Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to add sub router to application router #1343

Closed
Gr1N opened this issue Oct 28, 2016 · 2 comments
Closed

Ability to add sub router to application router #1343

Gr1N opened this issue Oct 28, 2016 · 2 comments
Labels

Comments

@Gr1N
Copy link

Gr1N commented Oct 28, 2016

Long story short

This proposal is about how to improve actual router to add possibility to include sub routers into main application router.

I big projects we want so split functionality into modules, e.g. module for users, module for news, etc. And each module can contains views, helpers, db tables, etc; and if module contains views we want to put routes in this module too. And for now there are no useful way to do it.

Expected behaviour

For example we have a project:

/users
   views.py
   router.py
/news
   views.py
   routes.py
main.py
routes.py

In top level router I just want something like this:

# routes.py
from users.routes import router as users_router
from news.routes import router as news_router

router = UrlDispatcher()
router.add_subrouter('/users', users_router, name_or_namespace='users')
router.add_subrouter('/news', news_router, name_or_namespace='news')

# main.py
from routes import router
app = Application(router=router)
...

In this case I don't want to create additional apps (using realization #1301) for news and users modules, because I don't need additional middlewares or signals, I just want to include routes.

@fafhrd91
Copy link
Member

you can use UrlDispatcher.register_resource. added in 3de9604

you'll need some variation of PrefixedSubAppResource but without app, would you like to provide PR?

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants