23 lines
595 B
Python
23 lines
595 B
Python
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(service)
|
|
else:
|
|
return None
|