'Serialize this query as URL query
@return: a Storage of URL variables'

def serialize_url(self, resource=None):

    op = self.op
    l = self.left
    r = self.right
    url_query = Storage()
    def _serialize(n, o, v, invert):
        try:
            quote = (lambda s: (s if (',' not in s) else ('"%s"' % s)))
            if isinstance(v, list):
                v = ','.join([quote(S3TypeConverter.convert(str, val)) for val in v])
            else:
                v = quote(S3TypeConverter.convert(str, v))
        except:
            return
        if ('.' not in n):
            if (resource is not None):
                n = ('~.%s' % n)
            else:
                return url_query
        if (o == self.LIKE):
            v = v.replace('%', '*')
        if (o == self.EQ):
            operator = ''
        else:
            operator = ('__%s' % o)
        if invert:
            operator = ('%s!' % operator)
        key = ('%s%s' % (n, operator))
        if (key in url_query):
            url_query[key] = ('%s,%s' % (url_query[key], v))
        else:
            url_query[key] = v
        return url_query
    if (op == self.AND):
        lu = l.serialize_url(resource=resource)
        url_query.update(lu)
        ru = r.serialize_url(resource=resource)
        url_query.update(ru)
    elif (op == self.OR):
        sub = self._or()
        if (sub is None):
            return url_query
        (n, o, v, invert) = sub
        _serialize(n, o, v, invert)
    elif (op == self.NOT):
        lu = l.serialize_url(resource=resource)
        for k in lu:
            url_query[('%s!' % k)] = lu[k]
    elif isinstance(l, S3FieldSelector):
        _serialize(l.name, op, r, False)
    return url_query
