[omniORB] Custom Servant Manager in Python

Stephan February stephan.february at gmail.com
Tue Oct 10 01:36:36 BST 2006


Hello

I am trying to implement a custom servant manager in Python as follows:

>8>8>8>8>8>8>8>8>8>8
FORTUNE_PATH="/usr/bin/fortune"

class CookieServer_i (Fortune__POA.CookieServer):
    def get_cookie(self):
        pipe = os.popen(FORTUNE_PATH)
        cookie = pipe.read()
        if pipe.close():
            cookie = "Oh dear, could'nt get a fortune\n"
        return cookie


class ResynServantManager(PortableServer__POA.ServantLocator):

    cookieServer = CookieServer_i()

    def preinvoke(self, oid, poa, operation, cookie):
        print "preinvoke : "
        return cookieServer

    def postinvoke(self, oid, adapter, operation, the_cookie, the_servant):
        print "postinvoke :"

orb = CORBA.ORB_init(sys.argv)
poa = orb.resolve_initial_references("RootPOA")

poaManager = poa._get_the_POAManager()

## NOTE: Deleted Naming Service Registration Code for brevity

# Setup RESYN POA
policies =[ poa.create_servant_retention_policy(PortableServer.NON_RETAIN),
    poa.create_request_processing_policy(PortableServer.USE_SERVANT_MANAGER
),
    poa.create_id_assignment_policy(PortableServer.USER_ID),
    poa.create_implicit_activation_policy(
PortableServer.NO_IMPLICIT_ACTIVATION),
    poa.create_thread_policy(PortableServer.ORB_CTRL_MODEL)]


resyn_servman = ResynServantManager()
resyn_poa = poa.create_POA("RESYN", poaManager, policies)

resyn_poa.set_servant_manager(resyn_servman._this())

#Activate the POA
poaManager.activate()

#Block until ORB is shutdown
orb.run()

>8>8>8>8>8>8>8>8>8>8

My problem is that the code never progresses past

    > resyn_poa.set_servant_manager()

i.e. it blocks at "set_servant_manager()" never activating the POA, and
therefore my requests don't get served.

If I call "poaManager.activate()" before the "set_servant_manager()" then
things seem to work OK, except that ResynServantManager() is not used to
"locate" my CookieServer objects.

I would like to know if anyone can help explain to me why my "RESYN" POA and
ResynServantManager() is never used for locating my CookieServer objects.
What am I missing/doing wrong.

Regards and thanks
Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20061010/70303318/attachment.htm


More information about the omniORB-list mailing list