def __construct__(self, ): if self.args is None: self.args = '' script = ["def %s(%s):"%(self.name, self.args)] script.extend( [" %s"%(x) for x in Helpers.normalizeScript(self.text).split('\n')] ) script = "\n".join(script) try: exec script in self.parent.__dict__ except Exception, msg: raise Exception("bad syntax in python block:\n %s" % msg)
def __construct__(self, ): """make a reference method that we can use to evaluate referenced nodes """ global node_uidcount_ if not self.delegate: self.funcname = self['name'] or "_%s_%s"%(self.on, node_uidcount_) node_uidcount_ += 1 args = self['args'] or "value" script = ["def %s(%s):"%(self.funcname, args)] script.extend( [" %s"%(x) for x in Helpers.normalizeScript(self.text).split('\n')] ) script = '\n'.join(script) try: exec script in self.parent.__dict__ except Exception, msg: raise "bad syntax in python block\n\n"+`msg` if self['reference']: self.parent.constrain(attr='early', func=self._reference) else: self.parent.constrain(attr=self.on, func=(self.delegate or self.parent.__dict__[self.funcname]), set=self.set )