Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong use of flask.globals resulting in unpredictable behaviour and possibly a big waste of your time #18

Open
wbeutels opened this issue Feb 26, 2021 · 3 comments

Comments

@wbeutels
Copy link

in flask_sijax.py:
def _on_before_request(self):
g.sijax = self
...
g's scope is the app context, not the request context

@wbeutels
Copy link
Author

the issue was not with the use of g but with the fact that flask_sijax.py basically uses a global var to store the per request instanciated sijax object, resulting in unwanted behaviour.

Anyway, I think I've fixed the issue by doing a find and replace of self._sijax to request.sijax.
Replace all g.sijax with request.sijax. (also in your htmls) and it should be fine.

If someone is still interested in using this lib, I've attached the modified version of flask_sijax.py.
flask_sijax.py.tar.gz

@spantaleev
Copy link
Owner

Is this a regression with some new version of Flask?

It's been working fine for me and I've never encountered any issue. Nor have I heard of anyone else report it.

I'm not doing any Python web development anymore, but.. If you'd like to submit a PR with this or any other fixes, I'd be happy to merge them and release a new version of Flask-Sijax, etc.

@wbeutels
Copy link
Author

It may well be due to a change in Flask. This issue only occurs when during processing of one sijax request another sijax request with a different path is made.t I'm using this lib at the moment so I'll do some more testing to make sure my changes work correctly before doing a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants