Changeset 336
- Timestamp:
- 06/13/08 17:12:38 (5 years ago)
- Location:
- elixir/trunk
- Files:
-
- 9 modified
-
CHANGES (modified) (1 diff)
-
elixir/entity.py (modified) (2 diffs)
-
elixir/ext/encrypted.py (modified) (2 diffs)
-
elixir/ext/versioned.py (modified) (8 diffs)
-
elixir/options.py (modified) (1 diff)
-
setup.py (modified) (1 diff)
-
tests/test_associable.py (modified) (1 diff)
-
tests/test_options.py (modified) (1 diff)
-
tests/test_sa_integration.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
elixir/trunk/CHANGES
r327 r336 12 12 identity for an entity. It also accepts a callable so that you can generate 13 13 the identity name automatically from the class itself. 14 15 Changes: 16 - require SQLAlchemy 0.4 14 17 15 18 Bug fixes: -
elixir/trunk/elixir/entity.py
r335 r336 14 14 ForeignKeyConstraint 15 15 from sqlalchemy.orm import Query, MapperExtension, \ 16 mapper, object_session, EXT_PASS, \ 16 mapper, object_session, \ 17 EXT_CONTINUE, \ 17 18 polymorphic_union 18 from sqlalchemy.ext.sessioncontext import SessionContext 19 try: 20 from sqlalchemy.ext.sessioncontext import SessionContext 21 except ImportError: 22 # Probably on sqlalchemy version 0.5 23 pass 19 24 20 25 import elixir … … 331 336 ret = func(instance) 332 337 # I couldn't commit myself to force people to 333 # systematicaly return EXT_PASS in all their event methods. 338 # systematicaly return EXT_CONTINUE in all their event 339 # methods. 334 340 # But not doing that diverge to how SQLAlchemy works. 335 # I should try to convince Mike to do EXT_ PASS by default,336 # and stop processing as the special case.337 # if ret != EXT_ PASS:338 if ret is not None and ret != EXT_ PASS:341 # I should try to convince Mike to do EXT_CONTINUE by 342 # default, and stop processing as the special case. 343 # if ret != EXT_CONTINUE: 344 if ret is not None and ret != EXT_CONTINUE: 339 345 return ret 340 return EXT_ PASS346 return EXT_CONTINUE 341 347 return proxy_method 342 348 -
elixir/trunk/elixir/ext/encrypted.py
r267 r336 29 29 from Crypto.Cipher import Blowfish 30 30 from elixir.statements import Statement 31 from sqlalchemy.orm import MapperExtension, EXT_ PASS31 from sqlalchemy.orm import MapperExtension, EXT_CONTINUE 32 32 33 33 __all__ = ['acts_as_encrypted'] … … 73 73 def before_insert(self, mapper, connection, instance): 74 74 perform_encryption(instance) 75 return EXT_ PASS75 return EXT_CONTINUE 76 76 77 77 def before_update(self, mapper, connection, instance): 78 78 perform_encryption(instance) 79 return EXT_ PASS79 return EXT_CONTINUE 80 80 81 81 def populate_instance(self, mapper, selectcontext, row, instance, 82 82 *args, **kwargs): 83 #FIXME: this is not available anymore in 0.5 84 #<jek> Gedd: on_load will do what you want here. 85 #the example in test/orm/instrumentation is the most succinct 83 86 mapper.populate_instance(selectcontext, instance, row, 84 87 *args, **kwargs) -
elixir/trunk/elixir/ext/versioned.py
r312 r336 50 50 51 51 from sqlalchemy import Table, Column, and_, desc 52 from sqlalchemy.orm import mapper, MapperExtension, EXT_ PASS, \52 from sqlalchemy.orm import mapper, MapperExtension, EXT_CONTINUE, \ 53 53 object_session 54 54 … … 89 89 instance.version = 1 90 90 instance.timestamp = datetime.now() 91 return EXT_ PASS91 return EXT_CONTINUE 92 92 93 93 def before_update(self, mapper, connection, instance): … … 100 100 # data. 101 101 ignored = instance.__class__.__ignored_fields__ 102 for key in instance. c.keys():102 for key in instance.table.c.keys(): 103 103 if key in ignored: 104 104 continue … … 111 111 break 112 112 113 return EXT_ PASS113 return EXT_CONTINUE 114 114 115 115 def before_delete(self, mapper, connection, instance): … … 117 117 get_history_where(instance) 118 118 )) 119 return EXT_ PASS119 return EXT_CONTINUE 120 120 121 121 … … 184 184 v = object_session(self).query(Version) \ 185 185 .filter(get_history_where(self)) \ 186 .order_by(Version. c.version) \186 .order_by(Version.version) \ 187 187 .all() 188 188 # history contains all the previous records. … … 201 201 query = object_session(self).query(Version) 202 202 query = query.filter(and_(get_history_where(self), 203 Version. c.timestamp <= dt))204 query = query.order_by(desc(Version. c.timestamp)).limit(1)203 Version.timestamp <= dt)) 204 query = query.order_by(desc(Version.timestamp)).limit(1) 205 205 return query.first() 206 206 … … 231 231 def compare_with(self, version): 232 232 differences = {} 233 for column in self. c:233 for column in self.table.c: 234 234 if column.name in ('version', 'concurrent_version'): 235 235 continue -
elixir/trunk/elixir/options.py
r323 r336 31 31 | | ``multi``. Defaults to ``single``. | 32 32 | | Note that polymorphic concrete inheritance is | 33 | | currently not implemented. | 33 | | currently not implemented. See: | 34 | | http://www.sqlalchemy.org/docs/04/mappers.html | 35 | | #advdatamapping_mapper_inheritance for an explanation | 36 | | of the different kinds of inheritances. | 34 37 +---------------------+-------------------------------------------------------+ 35 38 | ``polymorphic`` | Whether the inheritance should be polymorphic or not. | -
elixir/trunk/setup.py
r323 r336 25 25 license = "MIT License", 26 26 install_requires = [ 27 "SQLAlchemy >= 0. 3.9"27 "SQLAlchemy >= 0.4.0" 28 28 ], 29 29 packages=find_packages(exclude=['ez_setup', 'tests', 'examples']), -
elixir/trunk/tests/test_associable.py
r310 r336 84 84 assert '123 Elm St.' in streets 85 85 86 people = Person.select_addresses(and_(Address. c.street=='132 Elm St',87 Address.c .city=='Smallville'))86 people = Person.select_addresses(and_(Address.street=='132 Elm St', 87 Address.city=='Smallville')) 88 88 assert len(people) == 0 89 89 -
elixir/trunk/tests/test_options.py
r310 r336 114 114 115 115 def test_session_context(self): 116 from sqlalchemy.ext.sessioncontext import SessionContext 116 try: 117 from sqlalchemy.ext.sessioncontext import SessionContext 118 except ImportError: 119 # we are probably on SQLAlchemy 0.5, no need to test this. 120 return 117 121 118 122 engine = create_engine('sqlite:///') -
elixir/trunk/tests/test_sa_integration.py
r329 r336 25 25 Column('id', Integer, primary_key=True), 26 26 Column('name', String(60)), 27 Column('a_id', Integer, ForeignKey(A. c.id))27 Column('a_id', Integer, ForeignKey(A.id)) 28 28 ) 29 29 b_table.create()
