Changeset 340

Show
Ignore:
Timestamp:
06/17/08 17:36:07 (5 years ago)
Author:
ged
Message:

fix encrypted extension on SA0.5

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/ext/encrypted.py

    r336 r340  
    4848 
    4949 
     50try: 
     51    from sqlalchemy.orm import EXT_PASS 
     52    SA05orlater = False 
     53except ImportError: 
     54    SA05orlater = True 
     55 
    5056# 
    5157# acts_as_encrypted statement 
     
    7884                perform_encryption(instance) 
    7985                return EXT_CONTINUE 
    80              
     86         
     87        if SA05orlater: 
     88            def on_reconstitute(self, mapper, instance): 
     89                perform_decryption(instance) 
     90                return True 
     91            EncryptedMapperExtension.on_reconstitute = on_reconstitute 
     92        else: 
    8193            def populate_instance(self, mapper, selectcontext, row, instance,  
    8294                                  *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 
    8695                mapper.populate_instance(selectcontext, instance, row,  
    8796                                         *args, **kwargs) 
    8897                perform_decryption(instance) 
    8998                return True 
     99            EncryptedMapperExtension.populate_instance = populate_instance 
    90100         
    91101        # make sure that the entity's mapper has our mapper extension