Changeset 164

Show
Ignore:
Timestamp:
07/30/07 00:47:39 (5 years ago)
Author:
cleverdevil
Message:

Added some hooks to allow Elixir statements to perform some post-setup "finalization" which will be required for some upcoming Elixir extensions that I have in the works. Statements need only define a "finalize" class method that takes in an entity.

Location:
elixir/trunk/elixir
Files:
2 modified

Legend:

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

    r161 r164  
    117117        # try to setup all uninitialized relationships 
    118118        EntityDescriptor.setup_relationships() 
     119         
     120        # finally, allow the statement to do any "finalization" 
     121        Statement.finalize(self.entity) 
    119122     
    120123    def translate_order_by(self, order_by): 
  • elixir/trunk/elixir/statements.py

    r93 r164  
    2424        statements = class_locals.setdefault(STATEMENTS, []) 
    2525        statements.append((self, args, kwargs)) 
    26          
     26     
     27    @classmethod 
     28    def finalize(cls, entity): 
     29        for statement, args, kwargs in getattr(entity, STATEMENTS, []): 
     30            getattr(statement.target, 'finalize', lambda x: None)(entity) 
     31     
     32    @classmethod 
    2733    def process(cls, entity): 
    2834        ''' 
     
    3339        for statement, args, kwargs in getattr(entity, STATEMENTS, []): 
    3440            statement.target(entity, *args, **kwargs) 
    35     process = classmethod(process)