Changeset 505 for elixir/trunk
- Timestamp:
- 10/15/09 14:41:44 (3 years ago)
- Location:
- elixir/trunk
- Files:
-
- 5 modified
-
CHANGES (modified) (1 diff)
-
elixir/entity.py (modified) (1 diff)
-
elixir/options.py (modified) (2 diffs)
-
tests/test_custombase.py (modified) (2 diffs)
-
tests/test_options.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/CHANGES
r504 r505 1 1 0.8.0 2 2 3 Changes: 3 New features: 4 5 Changes: 6 - using_options_defaults and using_table_options statements can be used several 7 times within the same class (closes #70). 4 8 - Dropped support for python 2.3, SQLAlchemy 0.4 and deprecated stuff from 5 9 Elixir 0.7 6 10 7 11 Bug fixes: 8 - Fixed custom base s classes along side zope interfaces (closes #98, patch from9 Valentin Lab)12 - Fixed custom base classes and versioned extension when used with zope 13 interfaces (closes #98, patch from Valentin Lab) 10 14 11 15 0.7.0 - 2009-10-01 -
elixir/trunk/elixir/entity.py
r504 r505 145 145 self.identity = self.mapper_options['polymorphic_identity'] 146 146 else: 147 #TODO: include module name 147 #TODO: include module name (We could have b.Account inherit 148 # from a.Account) 148 149 self.identity = entity.__name__.lower() 149 150 elif 'polymorphic_identity' in self.mapper_options: -
elixir/trunk/elixir/options.py
r502 r505 231 231 raise Exception("'%s' is not a valid option for Elixir entities." 232 232 % kwarg) 233 234 entity.options_defaults = kwargs 233 if not hasattr(entity, 'options_defaults'): 234 entity.options_defaults = {} 235 entity.options_defaults.update(kwargs) 235 236 236 237 … … 245 246 246 247 def using_table_options_handler(entity, *args, **kwargs): 247 entity._descriptor.table_args = list(args)248 entity._descriptor.table_args.extend(list(args)) 248 249 entity._descriptor.table_options.update(kwargs) 249 250 -
elixir/trunk/tests/test_custombase.py
r504 r505 148 148 __metaclass__ = EntityMeta 149 149 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') 151 153 152 154 class TestA(OptionBase): 153 155 name = Field(String(32)) 154 156 155 class SuperTestB( OptionBase):157 class SuperTestB(TestA): 156 158 pass 157 159 … … 160 162 assert TestA.table.name == 'test_a' 161 163 assert SuperTestB.table.name == 'super_test_b' 164 assert TestA._descriptor.identity == 'test_a' 162 165 -
elixir/trunk/tests/test_options.py
r490 r505 60 60 setup_all(True) 61 61 62 raised = False63 62 try: 64 63 MyEntity._descriptor.add_column(Column('name', String(30))) 64 assert False 65 65 except Exception: 66 raised = True 67 68 assert raised 66 pass 69 67 70 68 def test_allowcoloverride_true(self): … … 204 202 205 203 def teardown(self): 206 cleanup_all( )204 cleanup_all(True) 207 205 208 206 def test_unique_constraint(self): 209 210 207 class Person(Entity): 211 208 firstname = Field(String(30)) … … 223 220 homer2 = Person(firstname="Homer", surname='Simpson') 224 221 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() 232 255 233 256 def test_unique_constraint_many_to_one(self):
