Help for "Ticket: Connection"

I saw this error “AttributeError: ‘Blueprint’ object has no attribute ‘json_encoder’” in the “python run.py” console.

In the http://localhost:5000/status page. It is shown like this:

Can someone tell me what could be wrong with my setup? Thanks!

Regards,
Chris Lee

you have to give us more then that.
looks like you have missed some step(s) in the Readme section
Show us your.ini file at least (edit out your cluster URL)

2 Likes

Hi torus_ot,

Thanks a lot for helping me. Here is my .ini file. My setup is on windows 10 environment:

[PROD]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@xxxx.mongodb.net/
MFLIX_NS = sample_mflix

[TEST]
SECRET_KEY = super_secret_testing_key
MFLIX_DB_URI = mongodb+srv://m220student:m220password@xxxx.mongodb.net/
MFLIX_NS = sample_mflix
<<<<<

When I run the following unit test, it seems it is fine. Here is the output:

C:\clee\mongo\class\m122p\mflix-python>pytest -m connection
============================= test session starts =============================
platform win32 – Python 3.7.3, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: C:\clee\mongo\class\m122p\mflix-python, inifile:
plugins: remotedata-0.3.1, openfiles-0.3.2, flask-0.10.0, doctestplus-0.3.0, arraydiff-0.3
collected 43 items

tests\test_db_connection.py … [100%]

============================= 39 tests deselected =============================
=================== 4 passed, 39 deselected in 6.71 seconds ===================
<<<<<

However, when I run the integrated testing. I have the following error:

C:\clee\mongo\class\m122p\mflix-python>python run.py

  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 295-745-842
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [21/Sep/2019 14:08:44] “GET /status HTTP/1.1” 200 -
    127.0.0.1 - - [21/Sep/2019 14:08:44] “GET /static/css/main.d2c98b4b.chunk.css HTTP/1.1” 304 -
    127.0.0.1 - - [21/Sep/2019 14:08:44] “GET /static/js/1.18f02ebe.chunk.js HTTP/1.1” 304 -
    127.0.0.1 - - [21/Sep/2019 14:08:44] “GET /static/js/main.a01f0687.chunk.js HTTP/1.1” 304 -
    127.0.0.1 - - [21/Sep/2019 14:08:45] “GET /static/media/mongoleaf.0ebc1843.png HTTP/1.1” 304 -
    127.0.0.1 - - [21/Sep/2019 14:08:45] “GET /static/media/pixelatedLeaf.6c93bd20.svg HTTP/1.1” 304 -
    127.0.0.1 - - [21/Sep/2019 14:08:46] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [21/Sep/2019 14:08:46] “GET /manifest.json HTTP/1.1” 200 -
    127.0.0.1 - - [21/Sep/2019 14:09:02] “GET /api/v1/movies/ HTTP/1.1” 500 -
    Traceback (most recent call last):
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py”, line 1997, in call
    return self.wsgi_app(environ, start_response)
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py”, line 1978, in wsgi_app
    ctx.push()
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\ctx.py”, line 332, in push
    self.session = self.app.open_session(self.request)
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\app.py”, line 912, in open_session
    return self.session_interface.open_session(self, request)
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\sessions.py”, line 324, in open_session
    s = self.get_signing_serializer(app)
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\sessions.py”, line 321, in get_signing_serializer
    signer_kwargs=signer_kwargs)
    File “C:\ProgramData\Anaconda3\lib\site-packages\itsdangerous\serializer.py”, line 95, in init
    self.is_text_serializer = is_text_serializer(serializer)
    File “C:\ProgramData\Anaconda3\lib\site-packages\itsdangerous\serializer.py”, line 13, in is_text_serializer
    return isinstance(serializer.dumps({}), text_type)
    File “C:\ProgramData\Anaconda3\lib\site-packages\flask\sessions.py”, line 85, in dumps
    return json.dumps(tag(value), separators=(’,’, ‘:’))
    File "C:\ProgramData\Anaconda3\lib\site-packages\flask\json_init
    .py", line 209, in dumps
    dump_arg_defaults(kwargs, app=app)
    File "C:\ProgramData\Anaconda3\lib\site-packages\flask\json_init
    .py", line 119, in _dump_arg_defaults
    “cls”, bp.json_encoder if bp and bp.json_encoder else app.json_encoder
    AttributeError: ‘Blueprint’ object has no attribute ‘json_encoder’
    <<<<<

I am wondering if anyone knows what is wrong with my setup. Thanks a lot!

Regards,
Chris Lee

Try to add your IP in whitelist in Atlas.

Also check that you correctly install sample databases

Can you try access your cluster from mongo shell?

Hi Yuliaya_68332 and torus_ot,

Thanks a lot for your help! Yes, I can connect to the database with mongo shell. But for some reason, when I ran the integration test, I kept getting the same error, even though the unit test was passed.

I finally set up everything on my old notebook which is running Windows 7, then everything works! Maybe there is some problem with Windows 10, or maybe I didn’t do everything right in Windows 10 environment. Anyway, I proceed with my assignment using the old notebook. Thanks you all !

Regards,
Chris Lee