class AssociationService(BaseService): """Example service implementation """ # Declaration of service declare = BaseService.service_declare(name='associations', version='0.1.0', dependencies=[]) # def __init__(self, receiver, spawnArgs=None): # BaseService.__init__(self, receiver, spawnArgs) # logging.info('HelloService.__init__()') def slc_init(self): self.store = Store() @defer.inlineCallbacks def op_put_association(self, content, headers, msg): ''' content is a DataObject encoding - a Dictionary! For storing blobs, we really just want to store it encoded. Can we get the serialized value from the messaging layer? ''' logging.info('op_put_association: '+str(content)) association = ValueObject(content) yield self.store.put(association.identity, association.value) # @ TODO add References! # The following line shows how to reply to a message yield self.reply(msg, 'reply', {'Stored Key':association.identity}, {}) @defer.inlineCallbacks def op_get_association(self, content, headers, msg): ''' ''' association = yield self.store.get(content['key']) # The following line shows how to reply to a message yield self.reply(msg, 'reply', association, {}) @defer.inlineCallbacks def op_del_association(self, content, headers, msg): ''' ''' # @ TODO remove References! yield self.store.delete(content['key']) # The following line shows how to reply to a message yield self.reply(msg, 'reply', {'result':'success'}, {})