Projet

Général

Profil

0001-don-t-staticly-replace-var_xxx-in-jsonp-url.patch

Thomas Noël, 27 janvier 2016 16:47

Télécharger (2,05 ko)

Voir les différences:

Subject: [PATCH] don't staticly replace [var_xxx] in jsonp url

 wcs/qommon/form.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
wcs/qommon/form.py
1705 1705
            vars = get_publisher().substitutions.get_context_variables()
1706 1706
            # skip variables that were not set (None)
1707 1707
            vars = dict((x, y) for x, y in vars.items() if y is not None)
1708
            url = misc.get_variadic_url(self.url, vars, encode_query=False)
1708
            # skip variables that can be dynamic (name start with "var_")
1709
            no_dynamic_vars = dict((x, y) for x, y in vars.items() if not x.startswith('var_'))
1710
            url = misc.get_variadic_url(self.url, no_dynamic_vars, encode_query=False)
1711
            dynamic_vars = dict((x, y) for x, y in vars.items() if x.startswith('var_'))
1709 1712
        else:
1710 1713
            url = self.url
1711 1714

  
......
1745 1748
function url_replace_%(id)s() {
1746 1749
    var url = $("#form_%(id)s").data('select2').opts.wcs_base_url;""" % {'id': self.name})
1747 1750
            for variable in variables:
1751
                default_value = dynamic_vars.get(variable + '_raw') or dynamic_vars.get(variable) or ''
1748 1752
                r += htmltext("""
1749 1753
    selector = '#' + $('#%(variable)s').data('valuecontainerid');
1750
    url = url.replace('[%(variable)s]', $(selector).val());""" % {'variable': variable})
1754
    value = $(selector).val() || %(default_value)s;
1755
    url = url.replace('[%(variable)s]', value);""" % {'default_value': json.dumps(default_value),
1756
                                                      'variable': variable})
1751 1757
            r += htmltext("""
1752 1758
    $("#form_%(id)s").data('select2').opts.ajax.url = url;
1753 1759
    $("#form_%(id)s").data('select2').clear();
1754
-