You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 line
1.2 KiB

  1. #!/usr/bin/python
  2. def getTraceback():
  3. import sys, traceback, string
  4. type, value, tb = sys.exc_info()
  5. body = "Traceback (innermost last):\n"
  6. list = traceback.format_tb(tb, None) + traceback.format_exception_only(type, value)
  7. body = body + "%-20s %s" % (string.join(list[:-1], ""), list[-1])
  8. return body
  9. try:
  10. import sys, os, cgi
  11. sys.path.append(os.path.join(os.path.dirname(__file__), 'cgi-bin'))
  12. import webnotes
  13. import webnotes.defs
  14. webnotes.form = cgi.FieldStorage()
  15. for each in webnotes.form.keys():
  16. webnotes.form_dict[each] = webnotes.form.getvalue(each)
  17. if webnotes.form.getvalue('cmd'):
  18. # AJAX Call
  19. import webnotes.handler
  20. else:
  21. # Page Call
  22. import webnotes.auth
  23. import webnotes.widgets.page_body
  24. webnotes.auth.HTTPRequest()
  25. print "Content-Type: text/html"
  26. # print cookies, if there ar additional cookies defined during the request, add them here
  27. if webnotes.cookies or webnotes.add_cookies:
  28. for c in webnotes.add_cookies.keys():
  29. webnotes.cookies[c] = webnotes.add_cookies[c]
  30. print webnotes.cookies
  31. print
  32. print webnotes.widgets.page_body.get()
  33. except Exception, e:
  34. d = {'exc':getTraceback()}
  35. import json
  36. print "Content-Type: text/html"
  37. print
  38. print json.dumps(d)