Is it possible to use a class instance in remote methods?
Daniel Krause <m.daniel.krause-gM/[email protected]>
| Newsgroups | gmane.comp.python.pyro |
|---|---|
| Message-ID | <CAMiLiKji-2q2h1QFcV-_SE8-wubJJEDw897iyP3wiSPhKdLOZg@mail.gmail.com> |
Hello,
I try to use a class instance in a remote method.
But so far I can only use single variables of the class instance (e.g.
method(class.variable)) in a remote method, but I can not use the class
instance itself (method(class) is not working).
Maybe I try something that is not intended:
Is it possible to use remote methods with class instances, and if yes, how?
Below is some code to illustrate my problem.
Daniel
'''
pyrotest_server.py
'''
import Pyro4
class Test(object):
def set(self, class_in):
self.new_class = class_in
if __name__ == '__main__':
Pyro4.config.DOTTEDNAMES = True
test = Test()
daemon=Pyro4.Daemon() # make a Pyro daemon
ns=Pyro4.locateNS() # find the name server
uri=daemon.register(test) # register as a Pyro object
ns.register("test", uri) # register the object with a name in the
name server
print 'test registered'
print "Ready."
daemon.requestLoop()
console output:
C:\Python27\lib\site-packages\pyro4-4.17-py2.7.egg\Pyro4\core.py:155:
UserWarnin
g: HMAC_KEY not set, protocol data may not be secure
warnings.warn("HMAC_KEY not set, protocol data may not be secure")
test registered
Ready.
'''
pyrotest_client.py
'''
import Pyro4
class ClassToSend(object):
def __init__(self):
self.var1 = "variable 1"
if __name__ == '__main__':
test = Pyro4.Proxy("PYRONAME:test")
class_to_send = ClassToSend()
try:
test.set(class_to_send.var1)
print 'test.set(class_to_send.var1) worked'
except Exception as e:
print 'exception on test.set(class_to_send.var1) occured: ', e
try:
test.set(class_to_send)
print 'test.set(class_to_send) worked'
except Exception as e:
print 'exception on test.set(class_to_send) occured: ', e
print 'done'
console output:
C:\Python27\lib\site-packages\pyro4-4.17-py2.7.egg\Pyro4\core.py:155:
UserWarnin
g: HMAC_KEY not set, protocol data may not be secure
warnings.warn("HMAC_KEY not set, protocol data may not be secure")
test.set(class_to_send.var1) worked
exception on test.set(class_to_send) occured: 'module' object has no
attribute
'ClassToSend'
done
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Pyro-core mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyro-core