[Lint] Make PyLint happy again
This commit is contained in:
parent
4935e6394b
commit
9e7ea29f5e
@ -21,7 +21,7 @@ from datetime import timedelta
|
|||||||
import pickle
|
import pickle
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
|
|
||||||
from flask import current_app, has_request_context, request, session
|
from flask import has_request_context, request as flask_request, session as flask_session
|
||||||
from flask.sessions import SessionInterface, SessionMixin
|
from flask.sessions import SessionInterface, SessionMixin
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from werkzeug.datastructures import CallbackDict
|
from werkzeug.datastructures import CallbackDict
|
||||||
@ -46,7 +46,7 @@ class CachedSession(CallbackDict, SessionMixin): # pylint: disable=too-many-anc
|
|||||||
self.__modifying = True
|
self.__modifying = True
|
||||||
|
|
||||||
if has_request_context():
|
if has_request_context():
|
||||||
self['ip'] = request.remote_addr
|
self['ip'] = flask_request.remote_addr
|
||||||
|
|
||||||
self.modified = True
|
self.modified = True
|
||||||
|
|
||||||
@ -59,6 +59,9 @@ class CachedSession(CallbackDict, SessionMixin): # pylint: disable=too-many-anc
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def user(self):
|
def user(self):
|
||||||
|
"""The user this session belongs to
|
||||||
|
"""
|
||||||
|
|
||||||
from calsocial.models import User
|
from calsocial.models import User
|
||||||
|
|
||||||
if 'user_id' not in self:
|
if 'user_id' not in self:
|
||||||
@ -87,11 +90,11 @@ class CachedSessionInterface(SessionInterface):
|
|||||||
return str(uuid4())
|
return str(uuid4())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_cache_expiration_time(app, session):
|
def get_cache_expiration_time(app, sess):
|
||||||
"""Get the expiration time of the cache entry
|
"""Get the expiration time of the cache entry
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if session.permanent:
|
if sess.permanent:
|
||||||
return app.permanent_session_lifetime
|
return app.permanent_session_lifetime
|
||||||
|
|
||||||
return timedelta(days=1)
|
return timedelta(days=1)
|
||||||
@ -147,7 +150,10 @@ class CachedSessionInterface(SessionInterface):
|
|||||||
domain=domain)
|
domain=domain)
|
||||||
|
|
||||||
def delete_session(self, sid):
|
def delete_session(self, sid):
|
||||||
if has_request_context() and session.sid == sid:
|
"""Delete the session with ``sid`` as its session ID
|
||||||
|
"""
|
||||||
|
|
||||||
|
if has_request_context() and flask_session.sid == sid:
|
||||||
raise ValueError('Will not delete the current session')
|
raise ValueError('Will not delete the current session')
|
||||||
|
|
||||||
cache.delete(self.prefix + sid)
|
cache.delete(self.prefix + sid)
|
||||||
|
@ -89,6 +89,9 @@ class RoutedMixin:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def register_routes(self):
|
def register_routes(self):
|
||||||
|
"""Register all routes that were marked with :meth:`route`
|
||||||
|
"""
|
||||||
|
|
||||||
for attr_name in self.__dir__():
|
for attr_name in self.__dir__():
|
||||||
attr = getattr(self, attr_name)
|
attr = getattr(self, attr_name)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user