Don't know if my "delete column function" could be part of web2py core functions but here it is :
def __del_sqltable_column(sqltable, column_name):
"""
For deleting a given column in an instance of web2py SQLTABLE class.
Pass the SQLTABLE object and the column name to delete.
Ex.: table1 = SQLTABLE(rows) contains id column and we want to delete it.
So we call __del_sqltable_column(tabel1, '
table.id') or
__del_sqltable_column(request.args(0), db[request.args(0)].id)
When the column name is changed with represent the representation should be
passed as column name.
"""
import re
regex_colum_name = re.compile(str(TH(column_name)))
for i in range(0, len(sqltable[0][0])):
if regex_colum_name.match(str(sqltable[0][0][i])):
for r in range(0, len(sqltable[1])):
del(sqltable[1][r][i])
del(sqltable[0][0][i])
return sqltable
return sqltable
It could be my first contribution to web2py ;-)
Richard