class OaiPmh(object): def __init__(self, repositoryName, adminEmail, repositoryIdentifier=None, batchSize=DEFAULT_BATCH_SIZE, supportXWait=False, externalUrl=None, preciseDatestamp=False): self._repository = OaiRepository( identifier=repositoryIdentifier, name=repositoryName, adminEmail=adminEmail, externalUrl=externalUrl, ) outside = Transparent() self.addObserver = outside.addObserver self.addStrand = outside.addStrand self._internalObserverTree = be( (Observable(), (OaiError(self._repository), (OaiIdentify(self._repository), (outside,) ), (OaiList(repository=self._repository, batchSize=batchSize, supportXWait=supportXWait), (OaiRecord(self._repository, preciseDatestamp=preciseDatestamp), (outside,) ) ), (OaiGetRecord(self._repository), (OaiRecord(self._repository, preciseDatestamp=preciseDatestamp), (outside,) ) ), (OaiListMetadataFormats(self._repository), (outside,) ), (OaiListSets(self._repository), (outside,) ), ) ) ) def updateRepositoryInfo(self, name=None, adminEmail=None): if name is not None: self._repository.updateName(name=name) if adminEmail is not None: self._repository.updateAdminEmail(adminEmail=adminEmail) def observer_init(self): list(compose(self._internalObserverTree.once.observer_init())) def handleRequest(self, Method, arguments, Body=None, **kwargs): if Method == 'POST': arguments.update(parse_qs(Body, keep_blank_values=True)) verb = arguments.get('verb', [None])[0] message = verb[0].lower() + verb[1:] if verb else '' yield self._internalObserverTree.all.unknown(message, arguments=arguments, **kwargs)