예제 #1
0
def thingy_dict_to_class(classname, d):
    print("{deserializer hook, converting to class: %s}" % d)
    return mycustomclasses.Thingy(d["number-attribute"])
예제 #2
0
 def method(self, arg):
     print("\nmethod called, arg=", arg)
     response = mycustomclasses.Thingy(999)
     return response
예제 #3
0
파일: client.py 프로젝트: zesem/Pyro5
    print("{deserializer hook, converting to class: %s}" % d)
    return mycustomclasses.Thingy(d["number-attribute"])


def otherthingy_dict_to_class(classname, d):
    print("{deserializer hook, converting to class: %s}" % d)
    return mycustomclasses.OtherThingy(d["number"])


# for 'Thingy' we register both serialization and deserialization hooks
register_class_to_dict(mycustomclasses.Thingy, thingy_class_to_dict)
register_dict_to_class("waheeee-custom-thingy", thingy_dict_to_class)

# for 'OtherThingy' we only register a deserialization hook (and for serialization depend on serpent's default behavior)
register_dict_to_class("mycustomclasses.OtherThingy",
                       otherthingy_dict_to_class)

# regular pyro stuff
uri = input("Enter the URI of the server object: ")
serv = Proxy(uri)
print("\nTransferring thingy...")
o = mycustomclasses.Thingy(42)
response = serv.method(o)
print("type of response object:", type(response))
print("response:", response)
print("\nTransferring otherthingy...")
o = mycustomclasses.OtherThingy(42)
response = serv.othermethod(o)
print("type of response object:", type(response))
print("response:", response)