Guest User

Untitled

a guest
May 25th, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.11 KB | None | 0 0
  1. from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
  2. from uwsgidecorators import postfork
  3. from lib import config as configapp
  4.  
  5. @postfork
  6. def init():
  7.     import __builtin__                                                                                                  
  8.     __builtin__.ConfigPhotoserver = configapp.ConfigPhotoserver
  9. #enddef
  10.  
  11. import rpcinterface as iface
  12. import uwsgi
  13.  
  14. dispatch = SimpleXMLRPCDispatcher()
  15.  
  16. def registerMethods():
  17.     dispatch.register_introspection_functions()
  18.     dispatch.register_function(iface.getGallery)
  19. #enddef
  20.  
  21. registerMethods()
  22.  
  23. def application(environ, start_response):
  24.  
  25.     if environ["REQUEST_METHOD"] != "POST":
  26.         start_response("500 Error", ())
  27.         return ["Only POST allowed"]
  28.  
  29.     try:
  30.         length = int(environ.get('CONTENT_LENGTH', None))
  31.     except (TypeError, ValueError):
  32.         length = -1
  33.  
  34.     request_text = environ["wsgi.input"].read(length)
  35.     response = dispatch._marshaled_dispatch(request_text)
  36.  
  37.     start_response("200 OK", [("Content-Type", "text/xml"), ("Content-Length", str(len(response)))])
  38.     return response
Advertisement
Add Comment
Please, Sign In to add comment