[Flask] Issues with Flash_session - Cannot add dict item ..

Ben Duncan linux4ms at gmail.com
Wed Sep 25 07:55:06 EDT 2019


Doing a dir on the Session defined in flask-session shows everything loaded.
I'm not sure, but I did this in the view after all the session stuff:

session{'status': 'GOOD'}

And another dir after this show the original stuff in there with a bunch of
new classes added.
Could be that a user dictionary isn't established unless you initiate it ...

I'd send the code samples, but alas OUR IT department has screwed up my
local connection to our VM's.... sigh ...

*Ben Duncan*
DBA / Chief Software Architect
Mississippi State Supreme Court
Electronic Filing Division


On Tue, Sep 24, 2019 at 1:12 PM Gergely Polonkai <gergely at polonkai.eu>
wrote:

> My first thought, without actual code to look at, is that you import
> session from flask globally, but you also create a session variable
> somewhere which is an instance of flask_session.Session.
>
> Can this be your culprit? Or are you positive that the session variable
> you use is the same as the one you create?
>
> Best,
> Gergely
>
> On Tue, 24 Sep 2019, 17:15 Ben Duncan, <linux4ms at gmail.com> wrote:
>
>> Ok, am i missing something ?
>>
>> View:
>>
>> from flask import Flask, render_template, request, redirect, url_for,
>> flash, make_response, escape, g
>> from flask_session import Session
>> from flask_sqlalchemy import SQLAlchemy
>> from flask import session
>>  .....
>>
>> app = Flask(__name__)
>> print 'APP is : ', app
>> csrf = CSRFProtect(app)
>>
>> session = Session()
>> session.init_app(app)
>>
>> When I try to do something like this:
>>
>> session['modified'] = False
>>
>> I get :
>>
>>    - e
>>    "/opt/rh/python27/root/usr/lib64/python2.7/site-packages/flask/app.py",
>>    line *1935*, in dispatch_request
>>
>>    return self.view_functions[rule.endpoint](**req.view_args)
>>
>>    - File "/data/flask/applications/myproject/wtform.py", line *334*, in
>>    contact
>>
>>    session['modified'] = False
>>
>>
>> TypeError: 'Session' object does not support item assignment
>>
>> What Am I doing wrong .... ?
>>
>>
>> *Ben Duncan*
>> DBA / Chief Software Architect
>> Mississippi State Supreme Court
>> Electronic Filing Division
>> _______________________________________________
>> Flask mailing list
>> Flask at python.org
>> https://mail.python.org/mailman/listinfo/flask
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/flask/attachments/20190925/a60075e5/attachment.html>


More information about the Flask mailing list