'Add additional view variables (invokes all callables)
@param output: the output dict
@param r: the S3Request
@param attr: the view variables (e.g. \'rheader\')
@note: overload this method in subclasses if you don\'t want
additional view variables to be added automatically'

@staticmethod
def _extend_view(output, r, **attr):

    if (r.interactive and isinstance(output, dict)):
        for key in attr:
            handler = attr[key]
            if callable(handler):
                resolve = True
                try:
                    display = handler(r)
                except TypeError:
                    display = handler
                    continue
                except:
                    raise
            else:
                resolve = False
                display = handler
            if (isinstance(display, dict) and resolve):
                output.update(**display)
            elif (display is not None):
                output[key] = display
            elif ((key in output) and callable(handler)):
                del output[key]
