/library/pygwt.py

http://pyjamas.googlecode.com/ · Python · 40 lines · 36 code · 4 blank · 0 comment · 0 complexity · 660df516f3a34d2cde49c344f05fd3b7 MD5 · raw file

  1. sNextHashId = 0
  2. def getNextHashId():
  3. global sNextHashId
  4. sNextHashId += 1
  5. return sNextHashId
  6. def getHashCode(o):
  7. JS("""
  8. return (o == null) ? 0 :
  9. (o.$H ? o.$H : (o.$H = pygwt_getNextHashId()));
  10. """)
  11. def getModuleName():
  12. JS("""
  13. return $moduleName;
  14. """)
  15. def getModuleBaseURL():
  16. JS("""
  17. // this is intentionally not using $doc, because we want the module's own url
  18. var s = document.location.href;
  19. // Pull off any hash.
  20. var i = s.indexOf('#');
  21. if (i != -1)
  22. s = s.substring(0, i);
  23. // Pull off any query string.
  24. i = s.indexOf('?');
  25. if (i != -1)
  26. s = s.substring(0, i);
  27. // Rip off everything after the last slash.
  28. i = s.lastIndexOf('/');
  29. if (i != -1)
  30. s = s.substring(0, i);
  31. return (s.length > 0) ? s + "/" : "";
  32. """)