Commits

Lucas van Dijk committed ac59ce2

Fixed sqlalchemy 0.6 incompatibility with non-sqlalchemy forms

Comments (0)

Files changed (1)

formalchemy/base.py

 from sqlalchemy.orm.dynamic import DynamicAttributeImpl
 from sqlalchemy.util import OrderedDict
 
+try:
+    from sqlalchemy.orm.exc import UnmappedInstanceError
+except ImportError:
+    class UnmappedInstanceError(Exception):
+        """
+            Exception to provide support for sqlalchemy < 0.6
+        """
+
+
 import fields, fatypes
 
 
                 # take object out of session, if present
                 try:
                     _obj_session = object_session(model)
-                except AttributeError:
+                except (AttributeError, UnmappedInstanceError):
                     pass # non-SA object; doesn't need session
                 else:
                     if _obj_session: