def construct_url(self, subpath="/", request=None, with_domain=False, secure=False):
		"""
		This method will do its best to construct a URL based on the Node's location. If with_domain is True, that URL will include a domain and a protocol; if secure is True as well, the protocol will be https. The request will be used to construct a domain in cases where a call to :meth:`Site.objects.get_current` fails.
		
		Node urls will not contain a trailing slash unless a subpath is provided which ends with a trailing slash. Subpaths are expected to begin with a slash, as if returned by :func:`django.core.urlresolvers.reverse`.
		
		Because this method will be called frequently and will always try to reverse ``philo-root``, the results of that reversal will be cached by default. This can be disabled by setting :setting:`PHILO_CACHE_PHILO_ROOT` to ``False``.
		
		:meth:`construct_url` may raise the following exceptions:
		
		- :class:`NoReverseMatch` if "philo-root" is not reversable -- for example, if :mod:`philo.urls` is not included anywhere in your urlpatterns.
		- :class:`Site.DoesNotExist <ObjectDoesNotExist>` if with_domain is True but no :class:`Site` or :class:`RequestSite` can be built.
		- :class:`~philo.exceptions.AncestorDoesNotExist` if the root node of the site isn't an ancestor of the node constructing the URL.
		
		:param string subpath: The subpath to be constructed beyond beyond the node's URL.
		:param request: :class:`HttpRequest` instance. Will be used to construct a :class:`RequestSite` if :meth:`Site.objects.get_current` fails.
		:param with_domain: Whether the constructed URL should include a domain name and protocol.
		:param secure: Whether the protocol, if included, should be http:// or https://.
		:returns: A constructed url for accessing the given subpath of the current node instance.
		
		"""
		# Try reversing philo-root first, since we can't do anything if that fails.
		if CACHE_PHILO_ROOT:
			key = "CACHE_PHILO_ROOT__" + settings.ROOT_URLCONF
			root_url = cache.get(key)
			if root_url is None:
				root_url = reverse('philo-root')
				cache.set(key, root_url)
		else:
			root_url = reverse('philo-root')
		
		try:
			current_site = Site.objects.get_current()
		except Site.DoesNotExist:
			if request is not None:
				current_site = RequestSite(request)
			elif with_domain:
				# If they want a domain and we can't figure one out,
				# best to reraise the error to let them know.
				raise
			else:
				current_site = None
		
		root = getattr(current_site, 'root_node', None)
		path = self.get_path(root=root)
		
		if current_site and with_domain:
			domain = "http%s://%s" % (secure and "s" or "", current_site.domain)
		else:
			domain = ""
		
		if not path or subpath == "/":
			subpath = subpath[1:]
		
		return '%s%s%s%s' % (domain, root_url, path, subpath)
dataset/ETHPy150Open ithinksw/philo/philo/models/nodes.py/Node.construct_url/original