'Ensure that only a single layer for each controller/function
is set as Default'

@staticmethod
def gis_layer_feature_onaccept(form):

    id = form.vars.id
    vars = form.vars
    c = vars.get('controller', None)
    f = vars.get('function', None)
    default = vars.get('style_default', None)
    if (default and c and f and id):
        db = current.db
        table = db.gis_layer_feature
        query = (((table.controller == c) & (table.function == f)) & (table.id != id))
        db(query).update(style_default=False)
    gis_layer_onaccept(form)
