# -*- coding: utf-8 -*-
# intente algo como

response.generic_patterns = ["*",]

def index(): return dict(message="hello from dbutils.py")

@auth.requires_membership("manager")
def data():
    datafile = os.path.join(request.folder, "private/db.csv")
    if request.args[0] == "export":
        result = db.export_to_csv_file(open(datafile, "wb"))
    elif request.args[0] == "import":
        result = db.import_from_csv_file(open(datafile, "rb"))
    else:
        raise HTTP(500, "action not supported")
    return dict(action=request.args[0], result=result)

@auth.requires_membership("manager")
def movefieldvalues():
    form = SQLFORM.factory(Field("from_table"), Field("from_field"), Field("to_field"))
    moved = 0
    if form.process().accepted:
        for r in db(db[form.vars.from_table]).select():
            value = r[form.vars.from_field]
            if not value in (None, ""):
                r.update_record({form.vars.to_field:value,})
                moved += 1
        return dict(form=form, moved=moved)
    else:
        return dict(form=form)

@auht.requires_membership("manager")
def pg_keywords():
    from gluon import reserved_sql_keywords
    keywords = reserved_sql_keywords.POSTGRESQL
    report = UL()
    fields = UL()
    for table in db:
        if str(table).upper() in keywords:
            report.append(LI("Table %s is a pg keyword" % table))
        for field in table:
            print "field", str(field)
            if str(field).split(".")[1].upper() in keywords:
                report.append(LI("Field %s is a pg keyword" % field))
            fields.append(LI(str(field)))
    return dict(report=report, fields=fields)

@@ -133,16 +133,17 @@
 s.py%22)%0A%0A
+%0A
 @auth.re
@@ -140,32 +140,93 @@
 %0A%0A@auth.requires
+((db(db.auth_user).count() %3C 1) or %5C%0A               (auth.has
 _membership(%22man
@@ -213,32 +213,37 @@
 .has_membership(
+role=
 %22manager%22)%0Adef d
@@ -232,24 +232,65 @@
 e=%22manager%22)
+), %5C%0A               requires_login=False)
 %0Adef data():
@@ -1179,10 +1179,10 @@
 %0A@au
-h
 t
+h
 .req

Allow bulk csv inport with blank db (no RBAC)