def encode(params, ignoreNoneValues=True):
    """Encode dict of p_params as a string of parameters ready to be
       incorporated into an URL. If p_ignoreNoneValues is True, every entry
       whose value is None is ignored."""
    if not params:
        return params
    r = []
    for name, value in params.items():
        if ignoreNoneValues and value is None:
            continue
        value = value if isinstance(value, str) else str(value)
        r.append('%s=%s' % (name, value))
    return '&'.join(r)
