Contact: fumanchu@aminus.org

Log in as guest/geniusql to create tickets

Changeset 115

Show
Ignore:
Timestamp:
08/03/07 13:49:42
Author:
fumanchu
Message:

Minor cleanups to logic.Expression.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/geniusql/logic.py

    r114 r115  
    249249        """Expression(func, [kwtypes={}]). func(obj, [**kw]) must return bool. 
    250250         
    251         func: a function, with one positional arg and optional keyword args, 
     251        func: a function, with positional args and optional keyword args, 
    252252            which must return bool. If func is None, it is initialized to 
    253253            "lambda x: True". 
     
    260260        """ 
    261261        if func is None: 
    262             self.func = lambda x: True 
     262            func = lambda x: True 
     263            self._load_func(func, False) 
    263264        else: 
    264             if earlybind: 
    265                 self._load_func(func) 
    266             else: 
    267                 self.func = func 
    268          
    269         # I can't believe this actually works (knock on wood). 
    270         self.func.func_globals.update(builtins) 
     265            self._load_func(func, earlybind) 
    271266         
    272267        if kwtypes is None: 
     
    275270        self.kwargs = {} 
    276271     
    277     def _load_func(self, func): 
     272    def _load_func(self, func, earlybind=True): 
    278273        # I can't believe this actually works (knock on wood). 
    279274        func.func_globals.update(builtins) 
    280         # Early-bind as much as possible. 
    281         binder = codewalk.EarlyBinder(func) 
    282         self.func = binder.function() 
     275        if earlybind: 
     276            # Early-bind as much as possible. 
     277            binder = codewalk.EarlyBinder(func) 
     278            self.func = binder.function() 
     279        else: 
     280            self.func = func 
    283281     
    284282    def code(self):