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

add few rules for one call function (routes function), class View #94

Closed
wants to merge 1 commit into from
Closed

Conversation

fanatid
Copy link

@fanatid fanatid commented Feb 10, 2013

it's attempt make routes more easy and add class based views

  • change route function
  • rename add_url_rule to add_route
  • change kwarg options to defaults
  • change url_for function
  • add class View in views.py -- this allow make common views (see test_plugin.TestBasicRouting.test_class_views for example)

@ghost ghost assigned jbeluch Feb 21, 2013
@fanatid
Copy link
Author

fanatid commented Mar 1, 2013

I think is no need reason include this pull request. Class and routes may use like this:

class BaseView(object):
    def view(self, *args, **kwargs):
        raise NotImplementedError

class View1(BaseView):
    def view(self):
        code1

class View2(BaseView):
    def view(self):
        code2

routes = (
    ('/view1', View1().view, 'view1'),
    ('/view2', View1().view, 'view2'),
)
for route in routes:
    plugin.add_url_rule(*route)

@fanatid fanatid closed this Mar 1, 2013
@dersphere
Copy link
Contributor

Even when there is no code change needed, I am quite sure @jbeluch would happily accept an PR to the docs where you describe this pattern in detail.
At least I would do ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants