Home Help Center

Creating Proxies for "Ice objects" with Python

hiaslhiasl Member Matthias WeberOrganization: University of Erlangen-NurembergProject: This baby is still nameless
Hi,

i want to write an application (using python) on which a client can create "Ice objects" via an interface.function returning a proxy for each object. for this i create an "Ice object" but i don't know how i can create the proxy object? Here is an example:

class A(IceSuperClass): #implementation of slice interface
...

def createA: #defind with slice
a = A()
return a

calling createA on client side results in an error similar to "wrong return value". Is there any function/method like "a.getProxy()" i can use? Btw. is it a must, that any proxy must be registered at Ice.adapter()?

Thanks & Bye
Matthias

Comments

  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi Matthias,

    We have a new support policy for the forum. Please see this post for details.

    Thanks,
    - Mark
  • hiaslhiasl Member Matthias WeberOrganization: University of Erlangen-NurembergProject: This baby is still nameless
    Hi Mark,

    better now? :)
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Thanks Matthias.

    In a server, you normally obtain a proxy from the object adapter, either as the return value of one of the adapter.add operations, or by calling adapter.createProxy.

    You can obtain a reference to the object adapter easily enough from the Ice.Current argument passed to createA:
    def createA(self, curr):
        id = Ice.stringToIdentity("theIdentityForA")
        proxy = curr.adapter.createProxy(id)
        return APrx.uncheckedCast(proxy)
    
    This is just one of many ways to do what you ask. This example shows how to create the proxy, but does not show how the Ice object is activated. It wasn't clear from your original post whether each call to createA should create a new object, or just a new proxy to an existing object.

    In any event, hopefully this will get you started. Let us know if you have more questions.

    Take care,
    - Mark
  • hiaslhiasl Member Matthias WeberOrganization: University of Erlangen-NurembergProject: This baby is still nameless
    Hi Mark,

    thanks for your answer. Indeed i want to create new an "Ice object" for each call and eactly one proxy for each one. How do i have to register those objects? May be, you could give me a small example?

    Thanks
    Matthias
  • mesmes CaliforniaAdministrators, ZeroC Staff Mark SpruiellOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    Hi,

    Here's one way to do it:
    def createA(self, curr):
        servant = AI()
        proxy = curr.adapter.addWithUUID(servant)
        return APrx.uncheckedCast(proxy)
    
    This example adds a new servant to the adapter's active servant map for each call to createA.

    Hope that helps,
    - Mark
Sign In or Register to comment.