Skip to content

fixed error caused by 'TypeError': unsupported operand type(s) for +=… #68

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/flask_track_usage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@

import six

from flask import _request_ctx_stack, g
# from flask import _request_ctx_stack, g # _request_ctx_stack is removed since flask-3.0.0
from flask import g
from flask.globals import request_ctx
try:
from flask_login import current_user
except Exception:
Expand Down Expand Up @@ -109,7 +111,8 @@ def before_request(self):
"""
Done before every request that is in scope.
"""
ctx = _request_ctx_stack.top
# ctx = _request_ctx_stack.top
ctx = request_ctx
view_func = self.app.view_functions.get(ctx.request.endpoint)
if self._type == 'exclude':
if view_func in self._exclude_views:
Expand All @@ -132,7 +135,8 @@ def after_request(self, response):
:Parameters:
- `response`: The response on it's way to the client.
"""
ctx = _request_ctx_stack.top
# ctx = _request_ctx_stack.top
ctx = request_ctx
view_func = self.app.view_functions.get(ctx.request.endpoint)
if self._type == 'exclude':
if view_func in self._exclude_views:
Expand Down
5 changes: 3 additions & 2 deletions src/flask_track_usage/summarization/mongoenginestorage.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ def increment(class_dict, src, dest, target_list):
if dest:
doc[dest] = value
doc.hits += 1
doc.transfer += src.content_length
doc.save()
if src.content_length:
doc.transfer += src.content_length
doc.save()


def generic_get_sum(
Expand Down