You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
791 B
Python

18 years ago
import xmlrpclib
from sugar.p2p.NotificationListener import NotificationListener
from sugar.p2p.model.AbstractModel import AbstractModel
class RemoteModel(AbstractModel):
18 years ago
def __init__(self, group, service):
18 years ago
AbstractModel.__init__(self)
self._service = service
18 years ago
self._group = group
18 years ago
addr = "http://%s:%d" % (service.get_address(), service.get_port())
self._client = xmlrpclib.ServerProxy(addr)
self._setup_notification_listener()
def get_value(self, key):
return self._client.get_value(key)
def set_value(self, key, value):
self._client.set_value(key, value)
def _setup_notification_listener(self):
name = self._service.get_name()
self._notification = NotificationListener(self._group, name)
self._notification.add_listener(self._notify_model_change)