def create_url(urlbase, urlargd, escape_urlargd=True, urlhash=None):
    """Creates a W3C compliant URL. Output will look like this:
    'urlbase?param1=value1&amp;param2=value2'
    @param urlbase: base url (e.g. config.CFG_SITE_URL/search)
    @param urlargd: dictionary of parameters. (e.g. p={'recid':3, 'of'='hb'}
    @param escape_urlargd: boolean indicating if the function should escape
                           arguments (e.g. < becomes &lt; or " becomes &quot;)
    @param urlhash: hash string to add at the end of the link
    """
    separator = '&amp;'
    output = urlbase
    if urlargd:
        output += '?'
        if escape_urlargd:
            arguments = [escape(quote(str(key)), quote=True) + '=' +
                         escape(quote(str(urlargd[key])), quote=True)
                         for key in urlargd.keys()]
        else:
            arguments = [str(key) + '=' + str(urlargd[key])
                         for key in urlargd.keys()]
        output += separator.join(arguments)
    if urlhash:
        output += "#" + escape(quote(str(urlhash)))
    return output
Creates a W3C compliant URL. Output will look like this:
    'urlbase?param1=value1&amp;param2=value2'
    @param urlbase: base url (e.g. config.CFG_SITE_URL/search)
    @param urlargd: dictionary of parameters. (e.g. p={'recid':3, 'of'='hb'}
    @param escape_urlargd: boolean indicating if the function should escape
                           arguments (e.g. < becomes &lt; or " becomes &quot;)
    @param urlhash: hash string to add at the end of the link