def render_detail(self, dataset): storedir = self.config.marv.storedir setdir = os.path.join(storedir, str(dataset.setid)) try: os.mkdir(setdir) except OSError: pass assert os.path.isdir(setdir), setdir store = Store(storedir, self.nodes) funcs = make_funcs(dataset, setdir, store) summary_widgets = [ x[0]._reader for x in # pylint: disable=protected-access [ store.load(setdir, node, default=None) for node in self.detail_summary_widgets ] if x ] sections = [ x[0]._reader for x in # pylint: disable=protected-access [ store.load(setdir, node, default=None) for node in self.detail_sections ] if x ] dct = { 'title': calltree(self.detail_title, funcs), 'sections': sections, 'summary': { 'widgets': summary_widgets } } detail = Detail.new_message(**dct).as_reader() dct = detail_to_dict(detail) fd = os.open(os.path.join(setdir, '.detail.json'), os.O_CREAT | os.O_EXCL | os.O_WRONLY, 0o666) jsonfile = os.fdopen(fd, 'w') json.dump(dct, jsonfile, sort_keys=True) jsonfile.close() os.rename(os.path.join(setdir, '.detail.json'), os.path.join(setdir, 'detail.json')) self._check_outdated(dataset)
def load(self, node): from marv_store import Store # pylint: disable=import-outside-toplevel store = Store(str(self._storedir), {node.name: node}) return store.load(str(self._setdir), node, default=None)
def load(self, node): from marv_store import Store storedir = current_app.site.config.marv.storedir store = Store(storedir, {node.name: node}) return store.load(self._setdir, node, default=None)