Beispiel #1
0
def build_query_string(request, params):
    """Builds a query string that includes the specified parameters along
    with those that were passed to the page.

    params is a dictionary.
    """
    query_parts = []

    for key, value in six.iteritems(request.GET):
        if key not in params:
            query_parts.append(urlencode({key: value}))

    for key, value in six.iteritems(params):
        if value is not None:
            query_parts.append(urlencode({key: value}))

    return '?' + '&'.join(query_parts)
Beispiel #2
0
 def get_url_params_except(self, *params):
     """
     Utility function to return a string containing URL parameters to
     this page with the specified parameter filtered out.
     """
     result = urlencode([
         (key, value)
         for key, value in six.iteritems(self.datagrid.request.GET)
         if key not in params
     ])
     return result + '&'
Beispiel #3
0
def get_url_params_except(query, *params):
    """Return a URL query string that filters out some params.

    This is used often when one wants to preserve some GET parameters and not
    others.
    """
    return urlencode([
        (key, value)
        for key, value in six.iteritems(query)
        if key not in params
    ])
Beispiel #4
0
def build_query_string(request, params):
    """Builds a query string that includes the specified parameters along
    with those that were passed to the page.

    params is a dictionary.
    """
    query_parts = []

    for key, value in six.iteritems(request.GET):
        if key not in params:
            query_parts.append(urlencode({
                key: value
            }))

    for key, value in six.iteritems(params):
        if value is not None:
            query_parts.append(urlencode({
                key: value
            }))

    return '?' + '&'.join(query_parts)