Project

General

Profile

« Previous | Next » 

Revision 2645

sql_gen.py: ColDict: Only allow dict inputs to constructor so update() can later be used. Ensure keys_table is a Table object.

View differences:

lib/sql_gen.py
179 179
    '''A dict that automatically makes inserted entries Col objects'''
180 180
    
181 181
    '''For params, see dict()'''
182
    def __init__(self, db, keys_table, *args, **kw_args):
183
        dict.__init__(self, *args, **kw_args)
182
    def __init__(self, db, keys_table, dict_={}):
183
        dict.__init__(self, dict_)
184 184
        
185
        keys_table = as_Table(keys_table)
186
        
185 187
        self.db = db
186 188
        self.table = keys_table
187 189
    
......
190 192
    
191 193
    def __setitem__(self, key, value):
192 194
        key = self._key(key)
193
        if value == None: value = self.db.col_default(key)
194 195
        return dict.__setitem__(self, key, as_Col(value, name=key.name))
195 196
    
196 197
    def update(self, dict_):

Also available in: Unified diff