'Update an ACL
@param group: the ID or UID of the auth_group this ACL applies to
@param c: the controller
@param f: the function
@param t: the tablename
@param record: the record (as ID or Row with ID)
@param oacl: the ACL for the owners of the specified record(s)
@param uacl: the ACL for all other users
@param entity: restrict this ACL to the records owned by this
entity (pe_id), specify "any" for any entity
@param delete: delete the ACL instead of updating it'

def update_acl(self, group, c=None, f=None, t=None, record=None, oacl=None, uacl=None, entity=None, delete=False):

    ANY = 'any'
    unrestricted = (entity == ANY)
    if unrestricted:
        entity = None
    table = self.table
    if (not table):
        return None
    s3 = current.response.s3
    if ('restricted_tables' in s3):
        del s3['restricted_tables']
    self.clear_cache()
    if ((c is None) and (f is None) and (t is None)):
        return None
    if (t is not None):
        c = f = None
    else:
        record = None
    if (uacl is None):
        uacl = self.NONE
    if (oacl is None):
        oacl = uacl
    success = False
    if group:
        group_id = None
        acl = dict(group_id=group_id, deleted=False, controller=c, function=f, tablename=t, record=record, oacl=oacl, uacl=uacl, unrestricted=unrestricted, entity=entity)
        if (isinstance(group, basestring) and (not group.isdigit())):
            gtable = self.auth.settings.table_group
            query = ((gtable.uuid == group) & (table.group_id == gtable.id))
        else:
            query = (table.group_id == group)
            group_id = group
        query &= ((((((table.controller == c) & (table.function == f)) & (table.tablename == t)) & (table.record == record)) & (table.unrestricted == unrestricted)) & (table.entity == entity))
        record = current.db(query).select(table.id, table.group_id, limitby=(0, 1)).first()
        if record:
            if delete:
                acl = dict(group_id=None, deleted=True, deleted_fk=('{"group_id":    %d}' % record.group_id))
            else:
                acl['group_id'] = record.group_id
            record.update_record(**acl)
            success = record.id
        elif group_id:
            acl['group_id'] = group_id
            success = table.insert(**acl)
        else:
            record = current.db((gtable.uuid == group)).select(gtable.id, limitby=(0, 1)).first()
            if record:
                acl['group_id'] = group_id
                success = table.insert(**acl)
    return success
