'Check whether the current user owns the record
@param table: the table or tablename
@param record: the record ID (or the Row if already loaded)
@param owners: override the actual record owners by a tuple
(realm_entity, owner_group, owner_user)
@return: True if the current user owns the record, else False'

def is_owner(self, table, record, owners=None, strict=False):

    auth = self.auth
    user_id = None
    sr = auth.get_system_roles()
    if (auth.user is not None):
        user_id = auth.user.id
    session = current.session
    roles = [sr.ANONYMOUS]
    if (session.s3 is not None):
        roles = (session.s3.roles or roles)
    if (sr.ADMIN in roles):
        return True
    elif (owners is not None):
        (realm_entity, owner_group, owner_user) = owners
    elif record:
        (realm_entity, owner_group, owner_user) = self.get_owners(table, record)
    else:
        return True
    if (not user_id):
        if isinstance(record, (Row, dict)):
            record_id = record[table._id.name]
        else:
            record_id = record
        if auth.s3_session_owns(table, record_id):
            return True
        else:
            return False
    if (owner_user and (owner_user == user_id)):
        return True
    if ((not any((realm_entity, owner_group, owner_user))) and (not strict)):
        return True
    elif strict:
        return False
    if (self.entity_realm and realm_entity):
        realms = auth.user.realms
        roles = [sr.ANONYMOUS]
        append = roles.append
        for r in realms:
            realm = realms[r]
            if ((realm is None) or (realm_entity in realm)):
                append(r)
    if (owner_group and (owner_group in roles)):
        return True
    else:
        return False
