def rewrite_internal_link(link):
 if (not link.startswith('#/')):
  return link
 from staticpages.models import AbstractPage
 virtual_path = link[2:]
 url = u'#'
 for page_model in AbstractPage.__subclasses__():
  try:
   page = page_model.objects.live().get(virtual_path=virtual_path)
   url = page.get_absolute_url()
  except ObjectDoesNotExist:
   pass
 return url

def rewrite_internal_link ( link ) : if ( not link . startswith ( '#/' ) ) : return link from staticpages . models import AbstractPage virtual_path = link [ 2 : ] url = u'#' for page_model in AbstractPage . __subclasses__ ( ) : try : page = page_model . objects . live ( ) . get ( virtual_path = virtual_path ) url = page . get_absolute_url ( ) except ObjectDoesNotExist : pass return url
converts link into an internal link .