def callback(context, name, factory): klass = factory.__name__ proxy = select_tables(klass) rec = proxy.first() if not rec: raise Exception("No table for class %s." % klass) rec = dict(rec) wrapped.table_name = rec['table'] from p2.datashackle.core.app.setobjectreg import setobject_type_registry setobject_type_registry.register_type(factory, self.maporder)
def register_remaining_tables(registered): res = select_tables() for rec in res: table_identifier = str(rec.table) class_name = str(rec.klass) if not class_name in registered: # There's no sa table type for this table yet. Create one and map to a generic ModelBase. registered.append(table_identifier) # Create SA table type table_type = Table(table_identifier, metadata, autoload=True) # Register table type setobject_table_registry.register_type(class_name, table_identifier, table_type) # Create a new setobject orm type setobject_type = create_basemodel_type(class_name, table_identifier, do_mapping=False) res.close()