How to change keys and values of a dict in pyro4?

38 Views Asked by At

I've recently been trying to make a little database using pyro4 to store a dict that would have the data stored in it. Here's my code:

import Pyro4

@Pyro4.expose
class Dict(object):
    def __init__(self):
        self._main = {}

    @property
    def main(self):
        return self._main

    # Only necessary when setting the property should be possible.
    @main.setter
    def main(self, value):
        self._main = value


daemon = Pyro4.Daemon()       
uri = daemon.register(Dict)

print("Ready. Object uri =", uri)     
daemon.requestLoop()

As you can see I have a getter and a setter to Dict._main, but that means that only the whole value can be changed! By that I mean (After the connection is resolved):

Will work (sample a):

Dict.main = {"apples":"are great"}

Won't work (sample b):

Dict.main['apples'] = "are great"

So is there another function or a way to be able to do something like in sample b? Thanks.

0

There are 0 best solutions below