home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1468 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.8 KB  |  48 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import cherrypy
  6.  
  7. def process_body():
  8.     
  9.     try:
  10.         import xmlrpclib
  11.         return xmlrpclib.loads(cherrypy.request.body.read())
  12.     except Exception:
  13.         return (('ERROR PARAMS',), 'ERRORMETHOD')
  14.  
  15.  
  16.  
  17. def patched_path(path):
  18.     if not path.endswith('/'):
  19.         path += '/'
  20.     
  21.     if path.startswith('/RPC2/'):
  22.         path = path[5:]
  23.     
  24.     return path
  25.  
  26.  
  27. def _set_response(body):
  28.     response = cherrypy.response
  29.     response.status = '200 OK'
  30.     response.body = body
  31.     response.headers['Content-Type'] = 'text/xml'
  32.     response.headers['Content-Length'] = len(body)
  33.  
  34.  
  35. def respond(body, encoding = 'utf-8', allow_none = 0):
  36.     import xmlrpclib
  37.     if not isinstance(body, xmlrpclib.Fault):
  38.         body = (body,)
  39.     
  40.     _set_response(xmlrpclib.dumps(body, methodresponse = 1, encoding = encoding, allow_none = allow_none))
  41.  
  42.  
  43. def on_error(*args, **kwargs):
  44.     body = str(sys.exc_info()[1])
  45.     import xmlrpclib
  46.     _set_response(xmlrpclib.dumps(xmlrpclib.Fault(1, body)))
  47.  
  48.