def genCode(self, indent, codeout, tagreg, tag): DTCompilerUtil.tagDebug(indent, codeout, tag) args=DTUtil.tagCall(tag, ['value']) nargs=DTCompilerUtil.pyifyArgs(tag, args) # Make sure this is a data component codeout.write ( indent, "if not locals().has_key('__return'):" ) codeout.write ( indent + 4, "raise __h.SkunkExcept.SkunkStandardError, '<:return:> tag encountered not inside of a data component'" ) # Ok, set the return value codeout.write ( indent, '__return = (%s)' % (nargs['value']) ) codeout.write ( indent, '__return_set = 1' ) # We need to exit now DTExcept.raiseHalt ( codeout, indent, 'return tag halt' )
def genCode(self, indent, codeout, tagreg, tag): DTCompilerUtil.tagDebug(indent, codeout, tag) args = DTUtil.tagCall(tag, [('until', 'None'), ('duration', 'None')]) if args['until'] == 'None' and args['duration'] == 'None': raise DTExcept.DTCompileError( tag, 'must supply either until or duration argument') args = DTCompilerUtil.pyifyArgs(tag, args) tempsecs = DTCompilerUtil.getTempName() if args['until'] != None: codeout.write( indent, '%s = __h.timeutil.convertUntil(%s)' % (tempsecs, args['until'])) elif args['duration'] != None: codeout.write( indent, '%s = __h.timeutil.convertDuration(%s)' % (tempsecs, args['duration'])) codeout.write(indent, '__expiration = %s' % tempsecs) ttupv = DTCompilerUtil.getTempName() codeout.write(indent, '%s = __h.time.localtime(%s)' % (ttupv, tempsecs)) codeout.write( indent, '__h.OUTPUT.write("<!-- cache expires:" + ' '__h.time.asctime(%s) + "-->")' % ttupv) codeout.write(indent, 'del %s, %s' % (ttupv, tempsecs))