You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
flask_zodb.py uses the UserDict.IterableUserDict class, which is replaced by collections.UserDict in Python 3.
Also, the ZODB.create_db method uses basestring, which is unavailable in Python.
This can be fixed easily with the following patch (I'll also make a pull request), making Flask-ZODB work with Python 3:
diff --git a/flask_zodb.py b/flask_zodb.py
index a950cf1..5c9f582 100644
--- a/flask_zodb.py
+++ b/flask_zodb.py
@@ -2,7 +2,11 @@ import flask
import transaction
import zodburi
-from UserDict import IterableUserDict
+try:
+ from collections import UserDict
+except ImportError: # for Python 2
+ from UserDict import IterableUserDict as UserDict
+
from ZODB.DB import DB
from contextlib import contextmanager, closing
from werkzeug.utils import cached_property
@@ -12,11 +16,17 @@ from persistent import Persistent as Object
from persistent.list import PersistentList as List
from persistent.mapping import PersistentMapping as Dict
+# Python 3 compatibility
+try:
+ basestring
+except NameError:
+ basestring = str
+
__all__ = ['ZODB', 'Object', 'List', 'Dict', 'BTree']
-class ZODB(IterableUserDict):
+class ZODB(UserDict):
"""Extension object. Behaves as the root object of the storage during
requests, i.e. a `~persistent.mapping.PersistentMapping`.
The text was updated successfully, but these errors were encountered:
SpotlightKid
changed the title
Use of IterableUserDict and basestring incompatible with Python 3
Use of IterableUserDict and basestring incompatible with Python 3
Apr 16, 2014
flask_zodb.py
uses theUserDict.IterableUserDict
class, which is replaced bycollections.UserDict
in Python 3.Also, the
ZODB.create_db
method usesbasestring
, which is unavailable in Python.This can be fixed easily with the following patch (I'll also make a pull request), making Flask-ZODB work with Python 3:
The text was updated successfully, but these errors were encountered: