def index_service(self): service_id = self.request.matchdict.get('service_id') self.csw.getrecordbyid(id=[service_id]) service = self.csw.records[service_id] settings = load_settings(self.request) from phoenix.tasks import index_thredds index_thredds.delay(url=service.source, maxrecords=settings.get('solr_maxrecords'), depth=settings.get('solr_depth')) self.session.flash('Start Indexing of Service %s. Reload page to see status ...' % service.title, queue="danger") return HTTPFound(location=self.request.route_path(self.name, tab="index"))
def panel(self): form = Form(schema=Schema(), buttons=('update',)) if 'update' in self.request.POST: try: controls = self.request.POST.items() appstruct = form.validate(controls) settings = load_settings(self.request) settings['solr_maxrecords'] = appstruct['maxrecords'] settings['solr_depth'] = appstruct['depth'] save_settings(self.request, settings) except ValidationFailure, e: logger.exception('validation of form failed.') return dict(title="Parameters", form=e.render()) except Exception, e: logger.exception('update failed.') self.request.session.flash('Update of Solr parameters failed. %s' % (e), queue='danger')
def appstruct(self): appstruct = {} settings = load_settings(self.request) appstruct['maxrecords'] = settings.get('solr_maxrecords', '-1') appstruct['depth'] = settings.get('solr_depth', '2') return appstruct