<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def document_url(self):
 """ Constructs and returns the document URL. :returns: Document URL """

        if '_id' not in self or self['_id'] is None:
            return None

        # handle design document url
        if self['_id'].startswith('_design/'):
            return '/'.join((
                self._database_host,
                url_quote_plus(self._database_name),
                '_design',
                url_quote(self['_id'][8:], safe='')
            ))

        # handle document url
        return '/'.join((
            self._database_host,
            url_quote_plus(self._database_name),
            url_quote(self['_id'], safe='')
        ))