def GET(self, key): i = web.input() raw = i.get("_raw") == "true" lst = get_list(key, raw=raw) if not lst or lst['type']['key'] == '/type/delete': raise web.notfound() web.header("Content-Type", self.content_type) return delegate.RawText(formats.dump(lst, self.encoding))
def GET(self, key): list = web.ctx.site.get(key) if not list: raise web.notfound() data = list.dict().get("seeds", []) text = formats.dump(data, self.encoding) return delegate.RawText(text)
def GET(self, key): i = web.input(limit=50, offset=0) limit = h.safeint(i.limit, 50) offset = h.safeint(i.offset, 0) editions = get_list_editions(key, offset=offset, limit=limit, api=True) if not editions: raise web.notfound() return delegate.RawText(formats.dump(editions, self.encoding), content_type=self.content_type)
def GET(self, key): lst = web.ctx.site.get(key) if not lst: raise web.notfound() i = web.input(limit=20) limit = h.safeint(i.limit, 20) data = self.get_subjects(lst, limit=limit) data['links'] = {"self": key + "/subjects", "list": key} text = formats.dump(data, self.encoding) return delegate.RawText(text, content_type=self.content_type)
def GET(self, key): list = web.ctx.site.get(key) if not list: raise web.notfound() i = web.input(limit=20, offset=0) limit = h.safeint(i.limit, 20) offset = h.safeint(i.offset, 0) data = list.get_editions(limit=limit, offset=offset, _raw=True) text = formats.dump(data, self.encoding) return delegate.RawText(text, content_type=self.content_type)
def GET(self, key): lst = web.ctx.site.get(key) if not lst: raise web.notfound() i = web.input(limit=20) limit = h.safeint(i.limit, 20) data = self.get_subjects(lst, limit=limit) data['links'] = { "self": key + "/subjects", "list": key } text = formats.dump(data, self.encoding) return delegate.RawText(text, content_type=self.content_type)
def POST(self, key): site = web.ctx.site lst = site.get(key) if not lst: raise web.notfound() if not site.can_write(key): raise self.forbidden() data = formats.load(web.data(), self.encoding) data.setdefault("add", []) data.setdefault("remove", []) # support /subjects/foo and /books/OL1M along with subject:foo and {"key": "/books/OL1M"}. process_seeds = lists_json().process_seeds for seed in process_seeds(data["add"]): lst.add_seed(seed) for seed in process_seeds(data["remove"]): lst.remove_seed(seed) seeds = [] for seed in data["add"] + data["remove"]: if isinstance(seed, dict): seeds.append(seed['key']) else: seeds.append(seed) changeset_data = { "list": { "key": key }, "seeds": seeds, "add": data.get("add", []), "remove": data.get("remove", []) } d = lst._save(comment="updated list seeds.", action="lists", data=changeset_data) web.header("Content-Type", self.content_type) return delegate.RawText(formats.dump(d, self.encoding))
def GET(self, key): lst = web.ctx.site.get(key) if not lst: raise web.notfound() seeds = [seed.dict() for seed in lst.get_seeds()] data = { "links": { "self": key + "/seeds", "list": key }, "size": len(seeds), "entries": seeds } text = formats.dump(data, self.encoding) return delegate.RawText(text)
def GET(self, key): lst = web.ctx.site.get(key) if not lst: raise web.notfound() i = web.input(limit=50, offset=0) limit = h.safeint(i.limit, 50) offset = h.safeint(i.offset, 0) editions = lst.get_editions(limit=limit, offset=offset, _raw=True) data = make_collection( size=editions['count'], entries=[self.process_edition(e) for e in editions['editions']], limit=limit, offset=offset) data['links']['list'] = key text = formats.dump(data, self.encoding) return delegate.RawText(text, content_type=self.content_type)
def POST(self, key): site = web.ctx.site lst = site.get(key) if not lst: raise web.notfound() if not site.can_write(key): raise self.forbidden() data = formats.load(web.data(), self.encoding) data.setdefault("add", []) data.setdefault("remove", []) # support /subjects/foo and /books/OL1M along with subject:foo and {"key": "/books/OL1M"}. process_seeds = lists_json().process_seeds for seed in process_seeds(data["add"]): lst.add_seed(seed) for seed in process_seeds(data["remove"]): lst.remove_seed(seed) seeds = [] for seed in data["add"] + data["remove"]: if isinstance(seed, dict): seeds.append(seed['key']) else: seeds.append(seed) changeset_data = { "list": {"key": key}, "seeds": seeds, "add": data.get("add", []), "remove": data.get("remove", []) } d = lst._save(comment="updated list seeds.", action="lists", data=changeset_data) web.header("Content-Type", self.content_type) return delegate.RawText(formats.dump(d, self.encoding))
def GET(self, key): lst = web.ctx.site.get(key) if not lst: raise web.notfound() i = web.input(limit=50, offset=0) limit = h.safeint(i.limit, 50) offset = h.safeint(i.offset, 0) editions = lst.get_editions(limit=limit, offset=offset, _raw=True) data = make_collection( size=editions['count'], entries=[self.process_edition(e) for e in editions['editions']], limit=limit, offset=offset ) data['links']['list'] = key text = formats.dump(data, self.encoding) return delegate.RawText(text, content_type=self.content_type)
def POST(self, key): site = web.ctx.site list = site.get(key) if not list: raise web.notfound() if not site.can_write(key): raise self.forbidden() data = formats.load(web.data(), self.encoding) for seed in data.get("add", []): list.add_seed(seed) for seed in data.get("remove", []): list.remove_seed(seed) d = list._save(comment="updated list seeds.") web.header("Content-Type", self.content_type) return delegate.RawText(formats.dump(d, self.encoding))
def dumps(self, data): web.header("Content-Type", self.content_type) return formats.dump(data, self.encoding)
def dumps(self, data): return formats.dump(data, self.encoding)
def GET(self, key): lst = get_list_seeds(key) if not lst: raise web.notfound() return delegate.RawText(formats.dump(lst, self.encoding))