def index(self): t = Template(file="data/templates/index.tmpl") conn = db.db(constants.DATABASE).getconnector() c = conn.cursor() c.execute("SELECT * FROM items;") t.title = "Shop And Share" t.rows = c.fetchall() return str(t)
def makeConfiguredParamsBody( templateName, variableList, versions ): template = Template( file=templatesPath() + templateName + '.tmpl' ) n = len( variableList ) template.n = n for t in range(1,versions+1): # print " t = " + `t` + " template " + templateName + "versions" + `versions` if t == 1: varList = variableList else: varList = makeVariablesInUpdateOrder( variableList ) p = 0 rows = [] for var in varList: p += 1 if var.arrayInfo != None: typ = 'Parameter_Text' default = 'null, Null_Unbounded_String' #'"'+var.arrayInfo.sqlArrayDefaultDeclaration( var.getDefaultAdaValue() )+'"' elif isIntegerTypeInPostgres( var ): typ = 'Parameter_Integer' default = '0' elif isBigIntTypeInPostgres( var ): typ = 'Parameter_Bigint' default = '0' elif var.isStringType(): typ = 'Parameter_Text' default = 'null, Null_Unbounded_String'; elif var.isNumericType(): typ = 'Parameter_Float' default = '0.0' elif var.isDateType(): typ = 'Parameter_Date' default = 'Clock' s = ' {0:>2d} => ( {1:s}, {2:s} )'.format( p, typ, default ) if( p < n ): s += "," s += " -- " + " : " + var.adaName + " (" + var.adaType +")" rows.append( s ) if t == 1: # print "adding insert rows" template.rows = rows else: # print "adding update rows" template.updateRows = rows return str(template)