Some work on the getting model back

This commit is contained in:
Marco Pesenti Gritti 2006-06-16 13:06:11 -04:00
parent 29fb2321fe
commit 4a0e8ac2d4
3 changed files with 10 additions and 38 deletions

View File

@ -106,18 +106,11 @@ class BrowserActivity(activity.Activity):
stype=_BROWSER_ACTIVITY_TYPE, properties=properties)
# Create our activity-specific browser sharing service
#self._model = self._group.get_store().create_model(url)
#self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
#self._update_shared_location()
#self.set_mode(BrowserActivity.LEADING)
self._model = LocalModel(stype)
self._model.set_value('owner', self._pservice.get_owner().get_nick_name())
self._update_shared_location()
self.set_mode(BrowserActivity.LEADING)
#bus = dbus.SessionBus()
#proxy_obj = bus.get_object('com.redhat.Sugar.Chat', '/com/redhat/Sugar/Chat')
#chat_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.ChatShell')
#chat_shell.send_text_message('<richtext><link href="' + escaped_address +
# '">' + escaped_title + '</link></richtext>')
def __title_cb(self, embed):
self.set_tab_text(embed.get_title())

View File

@ -19,9 +19,9 @@ class LocalModel(AbstractModel):
SERVICE_TYPE = "_olpc_model._tcp"
SERVICE_PORT = 6300
def __init__(self, group, model_id):
def __init__(self, pservice, model_id):
AbstractModel.__init__(self)
self._group = group
self._pservice = pservice
self._model_id = model_id
self._values = {}
@ -37,10 +37,11 @@ class LocalModel(AbstractModel):
self._notifier.notify(key)
def _setup_service(self):
service = Service(self._model_id, LocalModel.SERVICE_TYPE,
LocalModel.SERVICE_PORT)
self._service = self._pservice.share_activity(self,
stype=LocalModel.SERVICE_TYPE,
'', port=LocalModel.PORT_TYPE
properties=properties)
self._setup_server(service)
service.register(self._group)
# FIXME this is duplicated with StreamReader
def _setup_server(self, service):

View File

@ -1,22 +0,0 @@
from sugar.p2p.model.RemoteModel import RemoteModel
from sugar.p2p.model.LocalModel import LocalModel
class Store:
def __init__(self, group):
self._group = group
self._local_models = {}
def create_model(self, model_id):
model = LocalModel(self._group, model_id)
self._local_models[model_id] = model
return model
def get_model(self, model_id):
if self._local_models.has_key(model_id):
return self._local_models[model_id]
else:
service = self._group.get_service(model_id, LocalModel.SERVICE_TYPE)
if service:
return RemoteModel(self._group, service)
else:
return None