Show
Ignore:
Timestamp:
11/14/07 10:57:14 (6 years ago)
Author:
ged
Message:
  • cleanup class attributes (in the attributes-based syntax) after the
    property is attached to its entity, so that SQLAlchemy is not confused.
    Only caused problem in the case of single inheritance and when omitting
    some values. See SA ticket #866.
  • some PEP8 fixes
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • elixir/trunk/elixir/entity.py

    r265 r267  
    3333    # Not on sqlalchemy version 0.4 
    3434    ScopedSession = type(None) 
    35      
     35 
     36 
    3637def _do_mapping(session, cls, *args, **kwargs): 
    3738    if session is None: 
     
    5152            def __getattr__(s, key): 
    5253                return getattr(session.registry().query(cls), key) 
     54 
    5355            def __call__(s): 
    5456                return session.registry().query(cls) 
     
    252254                return 
    253255            elif self.inheritance == 'concrete': 
    254                # copy all columns from parent table 
    255                for col in self.parent._descriptor.columns: 
     256                # copy all columns from parent table 
     257                for col in self.parent._descriptor.columns: 
    256258                    self.add_column(col.copy()) 
    257                #FIXME: copy constraints. But those are not as simple to copy 
    258                #since the source column must be changed 
     259                #FIXME: copy constraints. But those are not as simple to copy 
     260                #since the source column must be changed 
    259261 
    260262        if self.polymorphic and self.inheritance in ('single', 'multi') and \ 
     
    524526 
    525527    def columns(self): 
    526         #FIXME: this would be more correct but it breaks inheritance, so I'll use the 
    527         # old test for now. 
     528        #FIXME: this would be more correct but it breaks inheritance, so I'll  
     529        # use the old test for now. 
    528530#        if self.entity.table: 
    529531        if self.autoload:  
     
    567569        return "<TriggerProxy (%s)>" % (self.class_.__name__) 
    568570 
     571 
    569572class TriggerAttribute(object): 
     573 
    570574    def __init__(self, attrname): 
    571575        self.attrname = attrname 
     
    581585def _is_entity(class_): 
    582586    return isinstance(class_, EntityMeta) 
     587 
    583588 
    584589class EntityMeta(type): 
     
    733738            method() 
    734739 
     740 
    735741def cleanup_entities(entities): 
    736742    """