| Paste number 42387: | CP3 xmlrpc issue 404's |
| Pasted by: | prologic |
| 1 year, 7 months ago | |
| None | |
| Paste contents: |
| File: authd.py #!/usr/bin/env python # Filename: authd.py # Module: authd # Date: 7th June 2007 # Author: James Mills, prologic at shortcircuit dot net dot au """Authentication Daemon Authentication Daemon for Zannee Broker Recruiting System. """ __description__ = "uthentication Daemon" __version__ = "0.0.1" __author__ = "James Mills" __author_email__ = "%s, prologic at shortcircuit dot net dot au" % __author__ __url__ = "http://shortcircuit.net.au/~prologic/" __copyright__ = "CopyRight (C) 2007 by %s" % __author__ __license__ = "GPL" import os cwd = os.path.join(os.getcwd()) CA = os.path.join(cwd, "authd.crt") KEY = os.path.join(cwd, "authd.key") import cherrypy from cherrypy import expose from pymills.db import Connection as DBConnection HTTPS_PORT = 9000 DATABASE = "mysql://prologic:4105701518@data/prologic_recruits" def newDB(idx): cherrypy.thread_data.db = DBConnection(DATABASE) def delDB(idx): if hasattr(cherrypy.thread_data, "db"): del cherrypy.thread_data.db class Root(object): db = property(lambda f: cherrypy.thread_data.db) req = property(lambda f: cherrypy.request) @expose def login(self, email, password): return "Not Implemented" def main(): cherrypy.engine.on_start_thread_list.append(newDB) cherrypy.engine.on_stop_thread_list.append(delDB) cherrypy.config.update("authd.ini") conf = { "/": { "tools.xmlrpc.on": True } } root = Root() cherrypy.tree.mount(root, "/", conf) cherrypy.server.quickstart() cherrypy.engine.start() if __name__ == "__main__": main() File: authd.ini [global] server.socket_port = 9000 server.ssl_certificate = "authd.crt" server.ssl_private_key = "authd.key" server.thread_pool = 10 ;environment = "production" ;log.screen = False ;log.error.file = "" File: login.py #!/usr/bin/env python import socket import xmlrpclib from traceback import format_exc URL = "https://localhost:9000/" def main(): try: server = xmlrpclib.ServerProxy(URL) print server.login("test", "test") except Exception, e: if isinstance(e, socket.error): if e[0] == 111: print "ERROR: %s" % e[1] else: print "ERROR: %s" % e print format_exc() if __name__ == "__main__": import sys main(*sys.argv[1:]) |
This paste has no annotations.