Importing a Flask-security instance into my views module breaks my webapp
Short Answer: You are missing blinker library. EDIT: You confirmed that your virtual environment could not find blinker and you re-installed it.
Long Answer:
I think the error is coming from Flask Signals. Look at this code from signals:
signals_available = False
try:
from blinker import Namespace
signals_available = True
except ImportError:
class Namespace(object):
def signal(self, name, doc=None):
return _FakeSignal(name, doc)
So I think that the code tries to find the blinker
library and in your case, it is not able to import it and hence it tries to use the _FakeSignal
class.
The _FakeSignal
class does not have a connect_via
attribute defined as you can see below
class _FakeSignal(object):
"""If blinker is unavailable, create a fake class with the same
interface that allows sending of signals but will fail with an
error on anything else. Instead of doing anything on send, it
will just ignore the arguments and do nothing instead.
"""
def __init__(self, name, doc=None):
self.name = name
self.__doc__ = doc
def _fail(self, *args, **kwargs):
raise RuntimeError('signalling support is unavailable '
'because the blinker library is '
'not installed.')
send = lambda *a, **kw: None
connect = disconnect = has_receivers_for = receivers_for = \
temporarily_connected_to = connected_to = _fail
del _fail
The connect_via
attribute that Flask-Security is trying to load is actually provided by the blinker
library and since no blinker, no connect_via. Hence it fails.
So you should install blinker first. However, I think that Flask-Security code should also check for blinker
before trying to use connect_via
.