Show
Ignore:
Timestamp:
03/27/07 11:15:20 (6 years ago)
Author:
ged
Message:

- The tablename option can now be given a callable so that people can provide

their own function to get the table name for an entity. The tablename option
can now also be set globally (using the options_defaults dictionary). Of
course, this only makes sense for the callable usecase.

Files:
1 modified

Legend:

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

    r94 r96  
    6565        # set default value for options 
    6666        self.order_by = None 
    67         self.tablename = None 
    6867        self.table_args = list() 
    6968        self.metadata = getattr(self.module, 'metadata', elixir.metadata) 
    7069 
    7170        for option in ('inheritance',  
    72                        'autoload', 'shortnames', 'auto_primarykey', 
     71                       'autoload', 'tablename', 'shortnames',  
     72                       'auto_primarykey', 
    7373                       'version_id_col'): 
    7474            setattr(self, option, options_defaults[option]) 
     
    9393                tablename = "%s_%s" % (modulename, entity.__name__) 
    9494                self.tablename = tablename.lower() 
     95        elif callable(self.tablename): 
     96            self.tablename = self.tablename(entity) 
    9597     
    9698    def setup(self):