Changeset 216

Show
Ignore:
Timestamp:
09/25/07 18:31:21 (6 years ago)
Author:
ged
Message:

added query to the attributes triggering the setup_all call

Location:
elixir/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/entity.py

    r214 r216  
    645645    def __getattribute__(cls, name): 
    646646        if type.__getattribute__(cls, "_ready"): 
    647             #TODO: we need to add all assign_mapper methods 
    648             if name in ('c', 'table', 'mapper'): 
     647            #TODO: we might want to add all columns that will be available as 
     648            #attributes on the class itself (in SA 0.4). This would be a pretty 
     649            #rare usecase, as people will hit the query attribute before the 
     650            #column attributes, but still... 
     651            if name in ('c', 'table', 'mapper', 'query'): 
    649652                elixir.setup_all() 
    650653        return type.__getattribute__(cls, name) 
  • elixir/trunk/tests/test_autosetup.py

    r215 r216  
    5151        assert isinstance(metadata.tables['person'], Table) 
    5252 
     53    def test_query(self): 
     54        class Person(Entity): 
     55            has_field('name', Unicode(30)) 
     56            using_options(tablename='person') 
     57 
     58        q = Person.query 
     59        assert isinstance(metadata.tables['person'], Table) 
     60