Changeset 505 for elixir/trunk

Show
Ignore:
Timestamp:
10/15/09 14:41:44 (3 years ago)
Author:
ged
Message:

- using_options_defaults and using_table_options statements can be used several

times within the same class (closes #70).

Location:
elixir/trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/CHANGES

    r504 r505  
    110.8.0 
    22 
    3 Changes: 
     3New features: 
     4 
     5Changes: 
     6- using_options_defaults and using_table_options statements can be used several 
     7  times within the same class (closes #70). 
    48- Dropped support for python 2.3, SQLAlchemy 0.4 and deprecated stuff from 
    59  Elixir 0.7 
    610 
    711Bug fixes: 
    8 - Fixed custom bases classes along side zope interfaces (closes #98, patch from 
    9   Valentin Lab) 
     12- Fixed custom base classes and versioned extension when used with zope 
     13  interfaces (closes #98, patch from Valentin Lab) 
    1014 
    11150.7.0 - 2009-10-01 
  • elixir/trunk/elixir/entity.py

    r504 r505  
    145145                self.identity = self.mapper_options['polymorphic_identity'] 
    146146            else: 
    147                 #TODO: include module name 
     147                #TODO: include module name (We could have b.Account inherit 
     148                # from a.Account) 
    148149                self.identity = entity.__name__.lower() 
    149150        elif 'polymorphic_identity' in self.mapper_options: 
  • elixir/trunk/elixir/options.py

    r502 r505  
    231231            raise Exception("'%s' is not a valid option for Elixir entities." 
    232232                            % kwarg) 
    233  
    234     entity.options_defaults = kwargs 
     233    if not hasattr(entity, 'options_defaults'): 
     234        entity.options_defaults = {} 
     235    entity.options_defaults.update(kwargs) 
    235236 
    236237 
     
    245246 
    246247def using_table_options_handler(entity, *args, **kwargs): 
    247     entity._descriptor.table_args = list(args) 
     248    entity._descriptor.table_args.extend(list(args)) 
    248249    entity._descriptor.table_options.update(kwargs) 
    249250 
  • elixir/trunk/tests/test_custombase.py

    r504 r505  
    148148            __metaclass__ = EntityMeta 
    149149 
    150             using_options_defaults(tablename=camel_to_underscore) 
     150            options_defaults = dict(tablename=camel_to_underscore) 
     151            using_options_defaults(identity=camel_to_underscore) 
     152            using_options_defaults(inheritance='multi') 
    151153 
    152154        class TestA(OptionBase): 
    153155            name = Field(String(32)) 
    154156 
    155         class SuperTestB(OptionBase): 
     157        class SuperTestB(TestA): 
    156158            pass 
    157159 
     
    160162        assert TestA.table.name == 'test_a' 
    161163        assert SuperTestB.table.name == 'super_test_b' 
     164        assert TestA._descriptor.identity == 'test_a' 
    162165 
  • elixir/trunk/tests/test_options.py

    r490 r505  
    6060        setup_all(True) 
    6161 
    62         raised = False 
    6362        try: 
    6463            MyEntity._descriptor.add_column(Column('name', String(30))) 
     64            assert False 
    6565        except Exception: 
    66             raised = True 
    67  
    68         assert raised 
     66            pass 
    6967 
    7068    def test_allowcoloverride_true(self): 
     
    204202 
    205203    def teardown(self): 
    206         cleanup_all() 
     204        cleanup_all(True) 
    207205 
    208206    def test_unique_constraint(self): 
    209  
    210207        class Person(Entity): 
    211208            firstname = Field(String(30)) 
     
    223220        homer2 = Person(firstname="Homer", surname='Simpson') 
    224221 
    225         raised = False 
    226         try: 
    227             session.commit() 
    228         except SQLError: 
    229             raised = True 
    230  
    231         assert raised 
     222        try: 
     223            session.commit() 
     224            assert False 
     225        except SQLError: 
     226            pass 
     227 
     228    def test_several_statements(self): 
     229        class A(Entity): 
     230            name1 = Field(String(30)) 
     231            name2 = Field(String(30)) 
     232            name3 = Field(String(30)) 
     233            using_table_options(UniqueConstraint('name1', 'name2')) 
     234            using_table_options(UniqueConstraint('name2', 'name3')) 
     235 
     236        setup_all(True) 
     237 
     238        a000 = A(name1='0', name2='0', name3='0') 
     239        a010 = A(name1='0', name2='1', name3='0') 
     240        session.commit() 
     241 
     242        a001 = A(name1='0', name2='0', name3='1') 
     243        try: 
     244            session.commit() 
     245            assert False 
     246        except SQLError: 
     247            session.close() 
     248 
     249        a100 = A(name1='1', name2='0', name3='0') 
     250        try: 
     251            session.commit() 
     252            assert False 
     253        except SQLError: 
     254            session.close() 
    232255 
    233256    def test_unique_constraint_many_to_one(self):