def get_page_instance(context):
 possible_names = [PAGE_TEMPLATE_VAR, u'self']
 for name in possible_names:
  if (name in context):
   page = context[name]
   if isinstance(page, Page):
    return page

def get_page_instance ( context ) : possible_names = [ PAGE_TEMPLATE_VAR , u'self' ] for name in possible_names : if ( name in context ) : page = context [ name ] if isinstance ( page , Page ) : return page
given a template context .