/addons/BoundMethod.py

http://pyjamas.googlecode.com/ · Python · 16 lines · 14 code · 1 blank · 1 comment · 0 complexity · 78e97acda8583a54ee5b6f31991b2812 MD5 · raw file

  1. from __pyjamas__ import JS
  2. def BoundMethod(obj, method):
  3. """
  4. Return a javascript-compatible callable which can be used as a "bound method".
  5. Javascript doesn't support callables, and it doesn't support bound methods,
  6. so you can't use those in pyjamas currently.
  7. This is an OK workaround.
  8. """
  9. JS("""
  10. return function() {
  11. return method.apply(obj, arguments);
  12. };
  13. """)