Commits

Anonymous committed 995fb14

[svn] * Updated Ajax commands to internally use 'with_' to avoid name conflicts with
Python 2.5 and beyond. Reported by anilj. Fixes #190.

  • Participants
  • Parent commits 5c532ad

Comments (0)

Files changed (3)

 WebHelpers ChangeLog
 
 0.2.3 (**svn**)
+* Updated Ajax commands to internally use 'with_' to avoid name conflicts with
+  Python 2.5 and beyond. Reported by anilj. Fixes #190.
 * Applied patch from David Smith to decude URL parts as Routes does.
   Fixes #186.
 * Changed pagination to give better response if its passed an invalid object.

File webhelpers/rails/prototype.py

                        'interactive','complete','failure','success'] + [str(x) for x in range(100,599)])
 AJAX_OPTIONS = frozenset(['before','after','condition','url',
                           'asynchronous','method','insertion','position',
-                          'form','with','update','script'] + list(CALLBACKS))
+                          'form','with','with_', 'update','script'] + list(CALLBACKS))
 
 def link_to_remote(name, options={}, **html_options):
     """
     in the background instead of regular reloading POST arrangement. 
     Keyword args are the same as in ``form_remote_tag``.    
     """
-    options['with'] = options.get('form') or 'Form.serialize(this.form)'
+    options['with_'] = options.get('form') or 'Form.serialize(this.form)'
     
     options['html'] = options.get('html') or {}
     options['html']['type'] = 'button'
     ``update``
         Specifies the DOM ID of the element whose innerHTML should be
         updated with the XMLHttpRequest response text.
-    ``with``
+    ``with_``
         A JavaScript expression specifying the parameters for the
         XMLHttpRequest. This defaults to 'value', which in the evaluated
         context refers to the new field value.
     identified by the DOM ID ``form_id``.
     
     Keyword args are the same as observe_field, except the default value of
-    the ``with`` keyword evaluates to the serialized (request string) value
+    the ``with_`` keyword evaluates to the serialized (request string) value
     of the form.
     """
     if options.get('frequency'):
         js_options['parameters'] = 'Form.serialize(this)'
     elif options.get('submit'):
         js_options['parameters'] = "Form.serialize('%s')" % options['submit']
-    elif options.get('with'):
-        js_options['parameters'] = options['with']
+    elif options.get('with_'):
+        js_options['parameters'] = options['with_']
     
     return options_for_javascript(js_options)
 
 def build_observer(cls, name, **options):
     if options.get('update') is True:
-        options['with'] = options.get('with', 'value')
+        options['with_'] = options.get('with', options.get('with_', 'value'))
     callback = remote_function(**options)
     javascript = "new %s('%s', " % (cls, name)
     if options.get('frequency'): 

File webhelpers/rails/scriptaculous.py

 def sortable_element_js(element_id, **options):
     if not isinstance(element_id, basestring):
         raise ValueError('Argument element_id must be a string')
-    options.setdefault('with', "Sortable.serialize('%s')" % element_id)
+    options.setdefault('with_', "Sortable.serialize('%s')" % element_id)
     options.setdefault('onUpdate', "function(){%s}" % remote_function(**options))
     for k in options.keys():
         if k in AJAX_OPTIONS: del options[k]
     return javascript_tag(drop_receiving_element_js(element_id, **options))
 
 def drop_receiving_element_js(element_id, **options):
-    options.setdefault('with', "'id=' + encodeURIComponent(element.id)")
+    options.setdefault('with_', "'id=' + encodeURIComponent(element.id)")
     options.setdefault('onDrop', "function(element){%s}" % remote_function(**options))
     for k in options.keys():
         if k in AJAX_OPTIONS: del options[k]