def _func_settings(self, func): #{{{
     mk_sig = self._vars['global_settings'].pop('MAKE_SIGNAL', 0)
     s = self._csettings()
     block = set(['ismethod', 'callmethod'])
     news = dict((k, v) for k, v in s.iteritems() if k not in block)
     ism = bool(s.get('ismethod', False))
     istup = isinstance(func, tuple)
     meth_app = self._vars['methods'].append
     # Add to methods var so callfunc can process both
     # conditional callables and target callables
     if ism:
         callmeth = bool(s.get('callmethod', False))
         if callmeth and not mk_sig:
             func_obj = func[1] if istup else func
             name, vardict = func_obj.__name__, dict()
             defstr, callstr = cargdefstr(func_obj)
             self_str = defstr.split(',', 1)[0].strip()
             callstr = callstr.split(',', 1)[1].strip()
             fstr = """
             def f(%s):
                 return getattr(%s, '%s')(%s)
             """ %(defstr, self_str, name, callstr)
             exec compile(fstr.strip(), '<string>', 'exec') in vardict
             f = vardict['f']
             func = (func[0], f) if istup else f
         if istup:
             for f in func:
                 meth_app(f)
         else:
             meth_app(func)
     return func, news
 def factory(func):
     defstr, callstr = cargdefstr(func)
     n = ''.join([_n.strip().replace('*', '').split('=')[0] for _n in defstr.split(',')])
     if not n or n == defstr:
         n = '_'.join(('g', n))
     global_code = "%s = self.connect_settings.get('globals', None)" %n
     exec compile(global_code, '<string>', 'exec') in locals()
     fstr = """
     def whenfunc(%s):
         return bool(eval('%s', %s, locals()))
     """ %(defstr, s.replace("'", "\\'"), n)
     exec compile(fstr.strip(), '<string>', 'exec') in locals()
     self._vars['settings']['weakcondf'] = False
     return condfunc(whenfunc)(func)
        def factory(func):
            defstr, callstr = cargdefstr(func)
            n = ''.join([_n.strip().replace('*', '').split('=')[0] for _n in defstr.split(',')])
            if not n or n == defstr:
                n = '_'.join(('g', n))
            global_code = "%s = self.connect_settings.get('globals', None)" %n
            exec compile(global_code, '<string>', 'exec') in locals()

            stoperr = StopCascade
            stop_code = "%s_stoperr = stoperr" %n
            exec compile(stop_code, '<string>', 'exec') in locals()
            fstr = """
            def cascadefunc(%s):
                ret = bool(eval('%s', %s, locals()))
                if bool(eval('%s', %s, locals())):
                    raise %s(ret)
                return ret
            """ %(defstr, s.replace("'", "\\'"), n, str(stop).replace("'", "\\'"), n, n + '_stoperr')
            exec compile(fstr.strip(), '<string>', 'exec') in locals()
            self._vars['settings']['weakcondf'] = False
            return condfunc(cascadefunc)(func)
 def settings(func): #{{{
     signal = getattr(func, 'signal', None)
     if isinstance(signal, DecoSignalExtension) and isinstance(signal, BaseSignal):
         locals().update(DecoSignalFunction=func)
     elif not _isf(func) and not isclass(func):
         raise TypeError('argument must be a python function or a python class')
     else:
         defstr, callstr = cargdefstr(func)
         signal = mkdeco(func, kwargs)
         fstr = """
         def DecoSignalFunction(%s):
             return signal(%s)
         """ %(defstr, callstr)
         exec compile(fstr.strip(), '<string>', 'exec') in locals()
     d = DecoSignalFunction
     d = wraps(func)(d)
     d.signal = signal
     for n in signal.decorators:
         setattr(d, n, getattr(signal, n))
     kwargs.pop('decoext', ())
     kwargs.pop('sigext', ())
     kwargs['MAKE_SIGNAL'] = 1
     return global_settings(d, **kwargs)(d)