code: def location_helper(name, search_only=False):
       
      try:
          return name.href
      except AttributeError:
          if name and name.startswith('http'):
              return name
      except ElementNotFound:
          return Location.create(name=name.name).href if not \
              search_only else None
          
      # Get all locations; tmp to support earlier 6.x versions.
      if name is not None:
          locations = [location for location in Search.objects.entry_point(
              'location') if location.name == name]
          if not locations:
              return Location.create(name=name).href if not search_only \
                  else None
          return locations[0].href
docs: Location finder by name. If location doesn't exist, create it
      and return the href
  
      :param str,Element name: location to resolve. If the location is
          by name, it will be retrieved or created, if href, returned
          and if Location, href returned. If None, settings an elements
          location to None will set it to the Default location.
      :param bool search_only: only search for the location, if not found
          do not create
      :return str href: href of location if search_only is not False
      :rtype: str or None