Package cobra :: Class CobraDaemon
[hide private]
[frames] | no frames]

Class CobraDaemon

source code


Instance Methods [hide private]
 
__init__(self, host="", port=COBRA_PORT, sslcrt=None, sslkey=None, sslca=None, msgpack=False)
Construct a cobra daemon object.
source code
 
setSslCa(self, crtfile)
Set the SSL Certificate Authority by this server.
source code
 
setSslServerCert(self, crtfile, keyfile)
Set the cert/key used by this server to negotiate SSL.
source code
 
fireThread(self) source code
 
stopServer(self) source code
 
serve_forever(self)
Handle one request at a time until shutdown.
source code
 
setAuthModule(self, authmod)
Enable an authentication module for this server ( all connections *must* be authenticated through the authmod )
source code
 
getSharedObject(self, name) source code
 
getSharedObjects(self)
Return a list of (name, obj) for the currently shared objects.
source code
 
getSharedName(self, obj)
If this object is shared already, get the name...
source code
 
getRandomName(self) source code
 
shareObject(self, obj, name=None, doref=False, dowith=False)
Share an object in this cobra server.
source code
 
getObjectRefCount(self, name) source code
 
decrefObject(self, name, ok=True)
Decref this object and if it reaches 0, unshare it.
source code
 
increfObject(self, name) source code
 
unshareObject(self, name, ok=True) source code

Inherited from SocketServer.ThreadingMixIn: process_request, process_request_thread

Inherited from SocketServer.TCPServer: close_request, fileno, get_request, server_activate, server_bind, server_close, shutdown_request

Inherited from SocketServer.BaseServer: finish_request, handle_error, handle_request, handle_timeout, shutdown, verify_request

Inherited from SocketServer.BaseServer (private): _handle_request_noblock

Class Variables [hide private]

Inherited from SocketServer.ThreadingMixIn: daemon_threads

Inherited from SocketServer.TCPServer: address_family, allow_reuse_address, request_queue_size, socket_type

Inherited from SocketServer.BaseServer: timeout

Method Details [hide private]

__init__(self, host="", port=COBRA_PORT, sslcrt=None, sslkey=None, sslca=None, msgpack=False)
(Constructor)

source code 

Construct a cobra daemon object.

Parameters: host - Optional hostname/ip to bind the service to (default: inaddr_any) port - The port to bind (Default: COBRA_PORT) msgpack - Use msgpack serialization

# SSL Options sslcrt / sslkey - Specify sslcrt and sslkey to enable SSL server side sslca - Specify an SSL CA key to use validating client certs

Overrides: SocketServer.BaseServer.__init__

setSslCa(self, crtfile)

source code 

Set the SSL Certificate Authority by this server. ( to validate client certs )

serve_forever(self)

source code 

Handle one request at a time until shutdown.

Polls for shutdown every poll_interval seconds. Ignores self.timeout. If you need to do periodic tasks, do them in another thread.

Overrides: SocketServer.BaseServer.serve_forever
(inherited documentation)

setAuthModule(self, authmod)

source code 

Enable an authentication module for this server
( all connections *must* be authenticated through the authmod )

NOTE: See cobra.auth.* for various auth module implementations

Example:
    import cobra.auth.shadow as c_a_shadow
    authmod = c_a_shadow.ShadowFileAuth('passwdfile.txt')
    cdaemon = CobraDaemon()
    cdaemon.setAuthModule()

getSharedObjects(self)

source code 

Return a list of (name, obj) for the currently shared objects.

Example:
    for name,obj in daemon.getSharedObjects():
        print('%s: %r' % (name,obj))

shareObject(self, obj, name=None, doref=False, dowith=False)

source code 

Share an object in this cobra server. By specifying doref=True you will let CobraProxy objects decide that the object is done and should be un-shared. Also, if name == None a random name is chosen. Use dowith=True to cause sharing/unsharing to enter/exit (requires doref=True).

Returns: name (or the newly generated random one)