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

Specialized decorators and flask classy do not play well together #35

Open
shuhaowu opened this issue Jun 17, 2013 · 1 comment
Open

Comments

@shuhaowu
Copy link
Contributor

I don't have a test case for now, but basically the idea is if you have in your route <id>, and if you want to apply some decorator def d(id, *args, **kwargs) selectively to some method of a view (so not using the decorators = []) approach, the id passed in will be self instead of the actual id

@ghost
Copy link

ghost commented Dec 2, 2014

I'm a newbie to python but maybe the following will help you:

def your_decorator(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        your_id = kwargs.id
        print(your_id)
        return func(*args, **kwargs)
    return wrapper

id is a named paramter and part of the kwargs dict, isn't it?

edit: oops, haven't seen that it's referenced to another issue.

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

No branches or pull requests

1 participant