Top "Decorator" questions

Decorator is an object-oriented design pattern that allows adding behavior to existing classes in a dynamic fashion.

Django: Staff Decorator

I'm trying to write a "staff only" decorator for Django, but I can't seem to get it to work: def …

django decorator
How to auto register a class when it's defined

I want to have an instance of class registered when the class is defined. Ideally the code below would do …

python oop design-patterns decorator metaclass
How to implement a decorator in PHP?

Suppose there is a class called "Class_A", it has a member function called "func". I want the "func" to …

php oop decorator
Django is_staff permission decorator

I am trying to limit access to pages using 2 user levels. Superuser and admin. Super user is a regular Django …

django permissions admin decorator
How to retry urllib2.request when fails?

When urllib2.request reaches timeout, a urllib2.URLError exception is raised. What is the pythonic way to retry establishing a …

python decorator urllib2 urllib3
Why would I ever use a Chain of Responsibility over a Decorator?

I'm just reading up on the Chain of Responsibility pattern and I'm having trouble imagining a scenario when I would …

oop design-patterns decorator chain-of-responsibility
Python - what are all the built-in decorators?

I know of @staticmethod, @classmethod, and @property, but only through scattered documentation. What are all the function decorators that are …

python decorator
How can I pass a variable in a decorator to function's argument in a decorated function?

I am in progress to learn Python. Hopefully someone points me to correct way. This is what I'd like to …

python decorator
How can I send variables to Jinja template from a Flask decorator?

Many routes around my blueprinted flask app will need to send 'sidebar data' to jinja. I'm looking for the most …

python templates flask decorator jinja2
Python - Get original function arguments in decorator

I am trying to write a "login_required" decorator for the views in a WSGI+Werkzeug application. In order to …

python decorator