##// END OF EJS Templates
fix(permissions): added a common way to update private flag via repo model...
fix(permissions): added a common way to update private flag via repo model - this allows to have a one and only one way to control the flag with the business logic shared - added test for that - changed view to use this method instead of DB update and custom permissions flush - fixed a case when update of repo settings didn't flush permissions actually while it should when private flag changed

File last commit:

r5040:444b916d default
r5551:5b9b5ed2 default
Show More
flask.py
48 lines | 1.4 KiB | text/x-python | PythonLexer
vendor-libs: synced authomatic code with latest changes
r5040
packages: vendor authomatic to provide bitbucket oath2 capabilities....
r3912 """
|flask| Extras
--------------
Utilities you can use when using this library with the |flask|_ framework.
Thanks to `Mark Steve Samson <http://marksteve.com>`_.
"""
vendor-libs: synced authomatic code with latest changes
r5040 from __future__ import absolute_import
packages: vendor authomatic to provide bitbucket oath2 capabilities....
r3912 from functools import wraps
from authomatic.adapters import WerkzeugAdapter
from authomatic import Authomatic
from flask import make_response, request, session
class FlaskAuthomatic(Authomatic):
"""
Flask Plugin for authomatic support.
"""
result = None
def login(self, *login_args, **login_kwargs):
"""
Decorator for Flask view functions.
"""
def decorator(f):
@wraps(f)
def decorated(*args, **kwargs):
self.response = make_response()
adapter = WerkzeugAdapter(request, self.response)
login_kwargs.setdefault('session', session)
login_kwargs.setdefault('session_saver', self.session_saver)
self.result = super(FlaskAuthomatic, self).login(
adapter,
*login_args,
**login_kwargs)
return f(*args, **kwargs)
return decorated
return decorator
def session_saver(self):
vendor-libs: synced authomatic code with latest changes
r5040 # FIXME: pylint false positive - see https://github.com/pallets/flask/issues/4020
session.modified = True # pylint: disable=assigning-non-slot