Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of PassingArgumentsToCallables


Ignore:
Timestamp:
05/11/06 13:28:06 (13 years ago)
Author:
mbevan
Comment:

Fixed a stupid bug in the order of arguments to make_list.

Legend:

Unmodified
Added
Removed
Modified
  • PassingArgumentsToCallables

    v1 v2  
    123123 
    124124{{{ 
    125 def make_list(c, *args, none=None, **kwargs): 
     125def make_list(c, none=None, *args, **kwargs): 
    126126    def _call(): 
    127127        return [ [], [('', none)] ][none is not None] + \ 
     
    134134{{{ 
    135135# Only list colors that have some red in them, and sort alphabetically. 
    136 widget = SingleSelectField('colors', options=make_list(Color, 'name', 
     136widget = SingleSelectField('colors', options=make_list(Color, None, 'name', 
    137137        Color.q.r > 0, orderBy=Color.q.name) 
    138138}}} 
     
    149149hub = __connection__ 
    150150 
    151 def make_list(c, *args, none_label=None, **kwargs): 
     151def make_list(c, none=None, *args, **kwargs): 
    152152    def _call(): 
    153         return [ [], [('', none_label)] ][none_label is not None] + \ 
     153        return [ [], [('', none)] ][none is not None] + \ 
    154154                c.build_list(*args, **kwargs) 
    155155    return _call 
     
    165165        return [(a.id, getattr(a, field)) for a in self.select(*args, **kwargs)] 
    166166 
    167 Color.list_bright = staticmethod(make_list(Color, 'name', 
     167Color.list_bright = staticmethod(make_list(Color, None, 'name', 
    168168            OR(OR(Color.q.r > 0.8, Color.q.g > 0.8, Color.q.b > 0.8), 
    169169                    (Color.q.r + Color.q.g + Color.q.b) > 2), 
    170170                    orderBy=Color.q.name)) 
    171 Color.list_shades = staticmethod(make_list(Color, 'name', 
     171Color.list_shades = staticmethod(make_list(Color, None, 'name', 
    172172            AND(Color.q.r == Color.q.g, Color.q.g == Color.q.b), 
    173173                    orderBy=Color.q.r))