Changeset 263

Show
Ignore:
Timestamp:
11/03/07 17:17:44 (6 years ago)
Author:
ged
Message:
  • minor style improvements, correct typos, ...
  • bump version to 0.4.1
Location:
elixir/trunk
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/TODO

    r253 r263  
    1212    - multiple files (modules) models 
    1313    - demonstrate common raltionships options (order_by, ...) 
     14    - inverse relationships matching (with a link to BehindTheScene) 
    1415 
    1516    ? autoload 
  • elixir/trunk/elixir/__init__.py

    r254 r263  
    1616''' 
    1717 
     18try: 
     19    set 
     20except NameError: 
     21    from sets import Set as set 
     22 
    1823import sqlalchemy 
    19  
    2024from sqlalchemy.types import * 
    2125 
     
    2630from elixir.fields import has_field, with_fields, Field 
    2731from elixir.relationships import belongs_to, has_one, has_many, \ 
    28                                  has_and_belongs_to_many 
    29 from elixir.relationships import ManyToOne, OneToOne, OneToMany, ManyToMany 
     32                                 has_and_belongs_to_many, \ 
     33                                ManyToOne, OneToOne, OneToMany, ManyToMany 
    3034from elixir.properties import has_property, GenericProperty, ColumnProperty 
    3135from elixir.statements import Statement 
    3236 
    33 try: 
    34     set 
    35 except NameError: 
    36     from sets import Set as set 
    3737 
    38 __version__ = '0.4.0' 
     38__version__ = '0.4.1' 
    3939 
    4040__all__ = ['Entity', 'EntityMeta', 
     
    5151 
    5252__doc_all__ = ['create_all', 'drop_all', 
    53                  'setup_all', 'cleanup_all', 
    54                  'metadata', 'session'] 
     53               'setup_all', 'cleanup_all', 
     54               'metadata', 'session'] 
    5555 
    5656 
  • elixir/trunk/elixir/ext/associable.py

    r236 r263  
    113113import elixir as el 
    114114import sqlalchemy as sa 
     115 
     116__doc_all__ = ['associable'] 
    115117 
    116118def associable(assoc_entity, plural_name=None, lazy=True): 
  • elixir/trunk/elixir/ext/encrypted.py

    r236 r263  
    1717        password = Field(Unicode) 
    1818        ssn = Field(Unicode) 
    19         acts_as_encrypted(for_columns=['password', 'ssn'], with_secret='secret') 
     19        acts_as_encrypted(for_columns=['password', 'ssn'],  
     20                          with_secret='secret') 
    2021 
    2122The above Person entity will automatically encrypt and decrypt the password and 
     
    2829from sqlalchemy.orm         import MapperExtension, EXT_PASS 
    2930 
     31__all__ = ['acts_as_encrypted'] 
     32__doc_all__ = [] 
    3033 
    3134# 
     
    3437 
    3538def encrypt_value(value, secret): 
    36     return Blowfish.new(secret, Blowfish.MODE_CFB).encrypt(value).encode('string_escape') 
     39    return Blowfish.new(secret, Blowfish.MODE_CFB) \ 
     40                   .encrypt(value).encode('string_escape') 
    3741 
    3842def decrypt_value(value, secret): 
    39     return Blowfish.new(secret, Blowfish.MODE_CFB).decrypt(value.decode('string_escape')) 
     43    return Blowfish.new(secret, Blowfish.MODE_CFB) \ 
     44                   .decrypt(value.decode('string_escape')) 
    4045 
    4146 
     
    7075                return EXT_PASS 
    7176             
    72             def populate_instance(self, mapper, selectcontext, row, instance, *args, **kwargs): 
    73                 mapper.populate_instance(selectcontext, instance, row, *args, **kwargs) 
     77            def populate_instance(self, mapper, selectcontext, row, instance,  
     78                                  *args, **kwargs): 
     79                mapper.populate_instance(selectcontext, instance, row,  
     80                                         *args, **kwargs) 
    7481                perform_decryption(instance) 
    7582                return True 
     
    8188acts_as_encrypted = Statement(ActsAsEncrypted) 
    8289 
    83  
    84 __all__ = [ 
    85     'acts_as_encrypted' 
    86 ] 
  • elixir/trunk/elixir/ext/versioned.py

    r221 r263  
    4444''' 
    4545 
    46 from elixir                import Integer, DateTime 
    47 from elixir.statements     import Statement 
     46from datetime              import datetime 
     47import inspect 
     48 
    4849from sqlalchemy            import Table, Column, and_, desc 
    4950from sqlalchemy.orm        import mapper, MapperExtension, EXT_PASS, \ 
    5051                                  object_session 
    51 from datetime              import datetime 
    52  
    53 import inspect 
    54  
     52 
     53from elixir                import Integer, DateTime 
     54from elixir.statements     import Statement 
     55 
     56__all__ = ['acts_as_versioned', 'after_revert'] 
     57__doc_all__ = [] 
    5558 
    5659# 
     
    6871def get_history_where(instance): 
    6972    clauses = [] 
     73    history_columns = instance.__history_table__.primary_key.columns 
    7074    for column in instance.table.primary_key.columns: 
    7175        instance_value = getattr(instance, column.name) 
    72         history_column = getattr(instance.__history_table__.primary_key.columns, column.name) 
     76        history_column = getattr(history_columns, column.name) 
    7377        clauses.append(history_column==instance_value) 
    7478    return and_(*clauses) 
     
    184188        # attach utility methods and properties to the entity 
    185189        def get_versions(self): 
    186             return object_session(self).query(Version).filter(get_history_where(self)).all() 
     190            return object_session(self).query(Version) \ 
     191                                       .filter(get_history_where(self)) \ 
     192                                       .all() 
    187193         
    188194        def get_as_of(self, dt): 
     
    238244        Version.compare_with = compare_with 
    239245 
    240 #def acts_as_versioned_handler(entity, ignore=[]): 
    241 #    builder = VersionedEntityBuilder(entity, ignore) 
    242 #    entity._descriptor.builders.append(builder) 
    243  
    244 #acts_as_versioned = ClassMutator(acts_as_versioned_handler) 
    245246acts_as_versioned = Statement(VersionedEntityBuilder) 
    246247 
    247248 
    248 # 
    249 # decorator for watching for revert events 
    250 # 
    251  
    252249def after_revert(func): 
     250    """ 
     251    Decorator for watching for revert events. 
     252    """ 
    253253    func._elixir_after_revert = True 
    254254    return func 
    255255 
    256256 
    257 __all__ = ['acts_as_versioned', 'after_revert'] 
  • elixir/trunk/elixir/relationships.py

    r244 r263  
    725725            # target's table 
    726726 
    727             # In some databases (at lease MySQL) the constraint names need  
     727            # In some databases (at least MySQL) the constraint names need  
    728728            # to be unique for the whole database, instead of per table. 
    729729            source_fk_name = "%s_fk" % source_part