def getContext(context):
    """Return a safe context.
    In case a IBrowserView was passed (e.g. due to a 404 page), return the
    portal object.
    """
    context = aq_parent(aq_base(context))
    if not context or IBrowserView.providedBy(context):
        return getSite()
    return context
def getContext ( context ) : context = aq_parent ( aq_base ( context ) ) if not context or IBrowserView . providedBy ( context ) : return getSite ( ) return context
Return a safe context.
    In case a IBrowserView was passed (e.g. due to a 404 page), return the
    portal object.