Changeset 169

Show
Ignore:
Timestamp:
08/01/07 01:58:31 (7 years ago)
Author:
cleverdevil
Message:

Added a method to EntityDescriptor for adding mapper extensions. Updated the events code to use it.

Location:
elixir/trunk/elixir
Files:
2 modified

Legend:

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

    r164 r169  
    192192        else: 
    193193            self.delayed_properties[name] = prop 
    194  
     194     
     195    def add_mapper_extension(self, extension): 
     196        extensions = self.mapper_options.get('extension', []) 
     197        if not isinstance(extensions, list): 
     198            extensions = [extensions] 
     199        extensions.append(extension) 
     200        self.mapper_options['extension'] = extensions 
     201     
    195202    def setup_table(self): 
    196203        ''' 
  • elixir/trunk/elixir/ext/events.py

    r168 r169  
    2424        # create a custom mapper extension class, tailored to our entity 
    2525        ext = type('EventMapperExtension', (MapperExtension,), methods)() 
    26  
     26         
    2727        # then, make sure that the entity's mapper has our mapper extension 
    28         extensions = entity._descriptor.mapper_options.get('extension', []) 
    29         if not isinstance(extensions, list): 
    30             extensions = [extensions] 
    31         extensions.append(ext) 
    32         entity._descriptor.mapper_options['extension'] = extensions 
     28        entity._descriptor.add_mapper_extension(ext) 
    3329 
    3430    def make_proxy_method(self, methods):