Show
Ignore:
Timestamp:
08/31/07 15:59:15 (6 years ago)
Author:
ged
Message:

more frame hackery so that one can use a class from another module in a relation target without prefixing
it by the module name if the target class as been imported in the local module.

Files:
1 modified

Legend:

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

    r196 r197  
    487487            return 
    488488 
    489         cid = cls._caller = id(sys._getframe(1)) 
     489        # build a dict of entities for each frame where there are entities 
     490        # defined 
     491        caller_frame = sys._getframe(1) 
     492        cid = cls._caller = id(caller_frame) 
    490493        caller_entities = EntityMeta._entities.setdefault(cid, {}) 
    491494        caller_entities[name] = cls 
     495 
     496        # Append all entities which are currently visible by the entity. This  
     497        # will find more entities only if some of them where imported from another 
     498        # module. 
     499        for entity in [e for e in caller_frame.f_locals.values()  
     500                         if e.__class__.__name__ == 'EntityMeta']: 
     501            caller_entities[entity.__name__] = entity 
    492502 
    493503        # create the entity descriptor