def from_dict(data): data = data.get("tag") if not is_ok(data): raise TypeError("Missing data: tag") if not is_ok(data.get("name")): raise TypeError("Missing data: tag.name") return Tag(name=data["name"])
def update_from_dict(self, data): data = data["post"] if not is_ok(data): raise TypeError("Missing data: post") if is_ok(data.get("title")): self.title = data["title"] if is_ok(data.get("body")): self.body = data["body"]
def from_dict(data): data = data["post"] if not is_ok(data): raise TypeError("Missing data: post") if not is_ok(data.get("title")): raise TypeError("Missing data: post.title") if not is_ok(data.get("body")): raise TypeError("Missing data: post.body") return Post(title=data["title"], body=data["body"])
def from_dict(data): data = data.get("topic") if not is_ok(data): raise TypeError("Missing data: topic") if not is_ok(data.get("name")): raise TypeError("Missing data: topic.name") return Topic(name=data["name"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes"))
def from_dict(data, archive=None): data = data.get("archive") if not is_ok(data): raise TypeError("Missing data: archive") if not is_ok(data.get("name")): raise TypeError("Missing data: archive.name") if (Archive.query.filter_by(name=data["name"]).first() or len(data["name"]) >= 128): raise TypeError("Invalid data: archive.name") return Archive(name=data["name"], notes=data.get("notes", ""))
def from_dict(data): data = data.get("box") if not is_ok(data): raise TypeError("Missing data: box") if not is_ok(data.get("number")): raise TypeError("Missing data: box.number") if Box.query.filter_by(number=data["number"]).first(): raise TypeError("Invalid data: box.number") return Box(number=data["number"], dates=data.get("dates"), notes=data.get("notes"))
def from_dict(data): data = data["post"] if not is_ok(data): raise TypeError("Missing data: post") if not is_ok(data.get("title")): raise TypeError("Missing data: post.title") if not is_ok(data.get("body")): raise TypeError("Missing data: post.body") return Post( title=data["title"], body=data["body"] )
def from_dict(data): data = data.get("topic") if not is_ok(data): raise TypeError("Missing data: topic") if not is_ok(data.get("name")): raise TypeError("Missing data: topic.name") return Topic( name=data["name"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes") )
def from_dict(data): data = data.get("document") if not is_ok(data): raise TypeError("Missing data: document") if not is_ok(data.get("title")): raise TypeError("Missing data: document.title") if (Document.query.filter_by(title=data["title"]).first() or len(data["title"]) >= 128): raise TypeError("Invalid data: document.title") return Document(title=data["title"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes"))
def from_dict(data): data = data.get("person") if not is_ok(data): raise TypeError("Missing data: person") if not is_ok(data.get("name")): raise TypeError("Missing data: person.name") if (Person.query.filter_by(name=data["name"]).first() or len(data["name"]) >= 128): raise TypeError("Invalid data: person.name") return Person(name=data["name"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes"))
def from_dict(data, archive=None): data = data.get("archive") if not is_ok(data): raise TypeError("Missing data: archive") if not is_ok(data.get("name")): raise TypeError("Missing data: archive.name") if (Archive.query.filter_by(name=data["name"]).first() or len(data["name"]) >= 128): raise TypeError("Invalid data: archive.name") return Archive( name=data["name"], notes=data.get("notes", "") )
def from_dict(data): data = data.get("document") if not is_ok(data): raise TypeError("Missing data: document") if not is_ok(data.get("title")): raise TypeError("Missing data: document.title") if (Document.query.filter_by(title=data["title"]).first() or len(data["title"]) >= 128): raise TypeError("Invalid data: document.title") return Document( title=data["title"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes") )
def from_dict(data): data = data.get("person") if not is_ok(data): raise TypeError("Missing data: person") if not is_ok(data.get("name")): raise TypeError("Missing data: person.name") if (Person.query.filter_by(name=data["name"]).first() or len(data["name"]) >= 128): raise TypeError("Invalid data: person.name") return Person( name=data["name"], dates=data.get("dates"), citations=data.get("citations"), notes=data.get("notes") )
def to_dict(self): rv = dict(tag=dict(id=self.id, name=self.name, posts=[dict(url=p.get_url()) for p in self.posts])) for key in list(rv["tag"]): if not is_ok(rv["tag"][key]): rv["tag"].pop(key, None) return rv
def to_dict(self): rv = dict(tag=dict( id=self.id, name=self.name, posts=[dict(url=p.get_url()) for p in self.posts] )) for key in list(rv["tag"]): if not is_ok(rv["tag"][key]): rv["tag"].pop(key, None) return rv
def to_dict(self): rv = dict(post=dict(id=self.id, title=self.title, body=self.body, html=self.html, timestamp=datetime.strftime( self.timestamp, '%b %d %Y %I:%M%p'), tags=[dict(url=t.get_url()) for t in self.tags])) for key in list(rv["post"]): if not is_ok(rv["post"][key]): rv["post"].pop(key, None) return rv
def to_dict(self): rv = dict(post=dict( id=self.id, title=self.title, body=self.body, html=self.html, timestamp=datetime.strftime( self.timestamp, '%b %d %Y %I:%M%p'), tags=[dict(url=t.get_url()) for t in self.tags] )) for key in list(rv["post"]): if not is_ok(rv["post"][key]): rv["post"].pop(key, None) return rv
def update_from_dict(self, data): data = data.get("tag") if not is_ok(data): raise TypeError("Missing data: tag") if is_ok(data.get("name")): self.name == data["name"]