You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
k4ever/k4ever/api2/decorators.py

24 lines
735 B

from functools import wraps
def changeUserOnPlugin(apiFunc):
""" Changes to a given user when the authenticated user is an plugin
When the user which called the apifunc is an plugin this function
goes through the following steps:
- searches the user it should change to
- checks if this user allowed the plugin to "speak for him"
- change the request so it looks like the user called himself
- add an plugin_user entry containing the previous request user
This decorator is intended to be used with django piston, so on error
it will return the appropriate rc.* values.
"""
@wraps(apiFunc)
def wrapper(self, request, *args, **kwargs):
return self.apiFunc(request, *args, **kwargs)
return wrapper