Show
Ignore:
Timestamp:
02/05/08 00:20:01 (5 years ago)
Author:
cleverdevil
Message:

Added a column_format keyword argument to ManyToMany which can be used to specify an alternate format string for column names in the mapping table. This is required to properly integrate with legacy TurboGears identity databases.

Files:
1 modified

Legend:

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

    r269 r297  
    225225|                    | by a minus (for descending order).                     | 
    226226+--------------------+--------------------------------------------------------+ 
     227| ``column_format``  | Specify an alternate format string for naming the      | 
     228|                    | columns in the mapping table.  The default value is    | 
     229|                    | defined in ``elixir.options.M2MCOL_NAMEFORMAT``.  You  | 
     230|                    | will be passed ``tablename``, ``key``, and ``entity``  | 
     231|                    | as arguments to the format string.                     | 
     232+--------------------+--------------------------------------------------------+ 
     233 
    227234 
    228235================ 
     
    671678        self.ondelete = kwargs.pop('ondelete', None) 
    672679        self.onupdate = kwargs.pop('onupdate', None) 
     680        self.column_format = kwargs.pop('column_format', options.M2MCOL_NAMEFORMAT) 
    673681 
    674682        self.secondary_table = None 
     
    749757             
    750758                for pk_col in desc.primary_keys: 
    751                     colname = options.M2MCOL_NAMEFORMAT % \ 
     759                    colname = self.column_format % \ 
    752760                              {'tablename': desc.tablename, 
    753                                'key': pk_col.key} 
    754  
     761                               'key': pk_col.key, 
     762                               'entity': desc.entity.__name__.lower()} 
     763                     
    755764                    # In case we have a many-to-many self-reference, we  
    756765                    # need to tweak the names of the columns so that we