jean-philippe serafin avatar jean-philippe serafin committed 879809c

Removed sqlalchemy import and isinstance() tests

Comments (0)

Files changed (2)



 import inspect
-import sqlalchemy
 from wtforms import fields as f
 from wtforms import validators
 from wtforms.form import Form
         self.converters = converters
     def convert(self, model, mapper, prop, field_args, db_session=None):
-        if not isinstance(prop, and \
-                not isinstance(prop,
+        if not hasattr(prop, 'columns') and not hasattr(prop, 'direction'):
-        elif isinstance(prop, and\
-            len(prop.columns) != 1:
+        elif not hasattr(prop, 'direction') and len(prop.columns) != 1:
             raise TypeError('Do not know how to convert multiple-column '
                 + 'properties currently')
         converter = None
         column = None
-        if isinstance(prop,
+        if not hasattr(prop, 'direction'):
             column = prop.columns[0]
             # Support sqlalchemy.schema.ColumnDefault, so users can benefit
             # from  setting defaults for fields, e.g.:
-        if db_session and isinstance(prop,
+        if db_session and hasattr(prop, 'direction'):
             foreign_model = prop.mapper.class_
             nullable = True
     field_dict = {}
     for name, prop in properties:
-        field = converter.convert(model, db_session, mapper, prop,
-            field_args.get(name))
+        field = converter.convert(model, mapper, prop,
+            field_args.get(name), db_session)
         if field is not None:
             field_dict[name] = field
         exclude = []
     model_mapper = model.__mapper__
     for prop in model_mapper.iterate_properties:
-        if isinstance(prop, and \
-               prop.columns[0].primary_key:
+        if not hasattr(prop, 'direction') and prop.columns[0].primary_key:
             if exclude_pk:
-        if isinstance(prop, \
-            and  exclude_fk and != 'MANYTOMANY':
-                for pair in prop.local_remote_pairs:
-                    exclude.append(pair[0].key)
+        if hasattr(prop, 'direction') and  exclude_fk and \
+       != 'MANYTOMANY':
+            for pair in prop.local_remote_pairs:
+                exclude.append(pair[0].key)
     type_name = type_name or model.__name__ + 'Form'
     field_dict = model_fields(model, db_session, only, exclude, field_args,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.