예제 #1
0
    def __init__(self, class_, includes=None, excludes=None, overrides=None, **kw):
        self.class_ = class_
        self.bootstrap = 'bootstrap_form_style' in kw
        schema = SQLAlchemySchemaNode(class_,
                                      includes=includes,
                                      excludes=excludes,
                                      overrides=overrides)
        self.inspector = inspect(class_)
        for prop in self.inspector.attrs:

            name = prop.key
            if name not in schema or not schema[name].widget is None:
                continue

            try:
                getattr(self.inspector.column_attrs, name)
                factory = 'get_widget_from_column'

            except AttributeError:
                getattr(self.inspector.relationships, name)
                factory = 'get_widget_from_relationship'

            schema[name].widget = getattr(self, factory)(prop)

        Form.__init__(self, schema, **kw)