Skip to content
Merged
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
12 changes: 1 addition & 11 deletions flask_mongoengine/operation_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
removes = []
response_sizes = []

if sys.version_info >= (3, 0):
unicode = str


# Wrap helpers._unpack_response for getting response size
@functools.wraps(_original_methods["_unpack_response"])
Expand Down Expand Up @@ -581,13 +578,6 @@ def _tidy_stacktrace():
hidden = True
if not text:
text = ""
else:
if sys.version_info >= (3, 0):
text = "".join(text).strip()
else:
try:
text = unicode("".join(text).strip())
except Exception:
pass
text = "".join(text).strip()
trace.append((path, line_no, func_name, text, hidden))
return trace, internal
10 changes: 4 additions & 6 deletions flask_mongoengine/sessions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import sys
import uuid

from bson.tz_util import utc
Expand All @@ -8,9 +7,6 @@

__all__ = ("MongoEngineSession", "MongoEngineSessionInterface")

if sys.version_info >= (3, 0):
basestring = str


class MongoEngineSession(CallbackDict, SessionMixin):
def __init__(self, initial=None, sid=None):
Expand All @@ -33,8 +29,8 @@ def __init__(self, db, collection="session"):
:param collection: The session collection name defaults to "session"
"""

if not isinstance(collection, basestring):
raise ValueError("collection argument should be string or unicode")
if not isinstance(collection, str):
raise ValueError("Collection argument should be string")

class DBSession(db.Document):
sid = db.StringField(primary_key=True)
Expand Down Expand Up @@ -82,6 +78,8 @@ def save_session(self, app, session, response):
domain = self.get_cookie_domain(app)
httponly = self.get_cookie_httponly(app)

# If the session is modified to be empty, remove the cookie.
# If the session is empty, return without setting the cookie.
if not session:
if session.modified:
response.delete_cookie(app.session_cookie_name, domain=domain)
Expand Down
7 changes: 2 additions & 5 deletions flask_mongoengine/wtf/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Useful form fields for use with the mongoengine.
"""
import json
import sys
from gettext import gettext as _

from mongoengine.queryset import DoesNotExist
Expand All @@ -15,9 +14,6 @@
"QuerySetSelectField",
)

if sys.version_info >= (3, 0):
unicode = str


class QuerySetSelectField(SelectFieldBase):
"""
Expand Down Expand Up @@ -171,10 +167,11 @@ def __init__(self, label="", validators=None, model=None, **kwargs):

class JSONField(TextAreaField):
def _value(self):
# TODO: Investigate why raw mentioned.
if self.raw_data:
return self.raw_data[0]
else:
return self.data and unicode(json.dumps(self.data)) or ""
return self.data and json.dumps(self.data) or ""

def process_formdata(self, value):
if value:
Expand Down
7 changes: 1 addition & 6 deletions flask_mongoengine/wtf/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Tools for generating forms based on mongoengine Document schemas.
"""
import decimal
import sys
from collections import OrderedDict

from bson import ObjectId
Expand All @@ -24,10 +23,6 @@
)


if sys.version_info >= (3, 0):
unicode = str


def converts(*args):
def _inner(func):
func._converter_for = frozenset(args)
Expand Down Expand Up @@ -234,7 +229,7 @@ def coerce(self, field_type):
"DecimalField": decimal.Decimal,
"ObjectIdField": ObjectId,
}
return coercions.get(field_type, unicode)
return coercions.get(field_type, str)


def model_fields(model, only=None, exclude=None, field_args=None, converter=None):
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[tool:pytest]
addopts = --cov=flask_mongoengine --cov-config=setup.cfg
testpaths = tests
env_override_existing_values = 1

[flake8]
ignore=E501,F403,F405,I201,W503,E203
Expand Down