'Approve all records in this resource
@param components: list of component aliases to include, None
for no components, empty list or tuple to
approve all components (default)
@param approve: set to approved (False to reset to unapproved)
@param approved_by: set approver explicitly, a valid auth_user.id
or 0 for approval by system authority'

def approve(self, components=(), approve=True, approved_by=None):

    if ('approved_by' not in self.fields):
        return True
    auth = current.auth
    if approve:
        if (approved_by is None):
            user = auth.user
            if user:
                user_id = user.id
            else:
                return False
        else:
            user_id = approved_by
    else:
        user_id = None
    db = current.db
    table = self._table
    pkey = self._id.name
    rows = self.select([pkey], limit=None, as_rows=True)
    if (not rows):
        return True
    record_ids = set()
    add = record_ids.add
    forget_permissions = auth.permission.forget
    for record in rows:
        record_id = record[pkey]
        forget_permissions(table, record_id)
        add(record_id)
    dbset = db(table._id.belongs(record_ids))
    try:
        success = dbset.update(approved_by=user_id)
    except:
        if current.response.s3.debug:
            raise
        success = False
    if (not success):
        db.rollback()
        return False
    onapprove = self.get_config('onapprove', None)
    if onapprove:
        rows = dbset.select(limitby=(0, len(record_ids)))
        for row in rows:
            callback(onapprove, row, tablename=self.tablename)
    if (components is None):
        return True
    if components:
        cdict = self.components
        components = [cdict[k] for k in cdict if (k in components)]
    else:
        components = self.components.values()
    for component in components:
        success = component.approve(components=None, approve=approve, approved_by=approved_by)
        if (not success):
            return False
    return True
