def table_crud(table): data = AttrDict() data.params = "" old_net = request.args.get("old_net", None) if old_net is not None: data.params = "?old_net=1" if table not in table_defs: return "Table %s is not available" % table datagrid = Datagrid(name="grid1", htmldiv="grid1", table=table) table_def = table_defs[table] columns = table_def.columns sortdata = table_def.sortdata data.primary_key = table_def.primary_key data.title = table_def.title data.table = table data.url = "/table/crud/%s" % table data.columns = [] for column in table_def.columns: name = column.name col = AttrDict() col.field = name col.caption = column.title col.size = "30%" col.sortable = True col.type = column.type data.columns.append(col) data.sortdata = [] data.sortdata.append( { 'field': sortdata[0]['name'], 'direction': sortdata[0]['direction'] } ) return render_template('table_crud.html', columns=columns,\ data = data, datajson=json.dumps(data), datagrid=datagrid)