Commits

pa...@paulj-PC.lab.pentest.co.uk  committed a58c566

Remove table_for

  • Participants
  • Parent commits babf8cd

Comments (0)

Files changed (2)

File tests/test_exception.py

     def setUp(self):
         raise NotImplementedError, "Must be subclassed."
 
-    def test_multiple_tables(self):
-        try:
-            tws.widgets.table_for(self.DBTestCls1)
-            assert(False)
-        except Exception, e:
-            assert(str(e) == 'Can only act on entities that map to a single table')
 
 # TODO -- How can we test this with Elixir?
 

File tw2/sqla/widgets.py

                 yield (i,j)
 
 
-def table_for(entity):
-    mapper = sa.orm.class_mapper(entity)
-    if len(mapper.tables) != 1:
-        raise twc.WidgetError('Can only act on entities that map to a single table')
-    return mapper.tables[0]
-
 def is_manytoone(prop):
     return isinstance(prop, sa.orm.RelationshipProperty) and \
             prop.direction.name == 'MANYTOONE'
 
     def __init__(self, entity, **kw):
         super(RelatedValidator, self).__init__(**kw)
-        cols = list(table_for(entity).primary_key.columns)
+        cols = sa.orm.class_mapper(entity).primary_key
         if len(cols) != 1:
             raise twc.WidgetError('RelatedValidator can only act on tables that have a single primary key column')
         self.entity = entity