Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Refactoring class based views #85

Open
borntyping opened this issue Mar 9, 2013 · 0 comments
Open

Refactoring class based views #85

borntyping opened this issue Mar 9, 2013 · 0 comments

Comments

@borntyping
Copy link
Member

Considering modifying the way routing is done to be a bit clearer, and avoid some of the mess of class-based routes. It'd look a bit like this[1]:

@entity.get('/profile', endpoint='profiles')
def get_all_profiles():
    ...

@entity.post('/profile', endpoint='new_profile')
@require_authorization
def new_profile():
    ... 

instead of like this:

@entity.route_class('/profile', endpoint='profiles')
class ProfilesView(MethodView):

    def get(self):
        ...

    @require_authorization
    def post(self):
        ...

A major advantage of this would be that endpoint and function names would be a lot more descriptive (as well as avoiding multiple endpoints under the same name), though it would result in having to repeat the route name (I'm not so sure this is such as bad thing). What do people think of this?

  1. Note - we can already do much the same thing with @blueprint.route(..., methods=['GET']), which would be how this would be implemented internally.
@ghost ghost assigned borntyping Mar 9, 2013
@borntyping borntyping removed their assignment May 7, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant