class WikiPageView(BaseResource): def __init__(self, request): super(WikiPageView, self).__init__(request) self.mgr = WikiPageManager(request.trfdb) self.wikicollector = WikiCollector() self.limit = 25 def collection_query(self): return self.mgr.query() def get(self): name = self.request.matchdict["name"] p = self.mgr.get_by_name(name) if p is None: try: data = self.wikicollector.get_wiki_page(name) except HTTPError, e: data = None if data is not None: with transaction.manager: p = WikiPage() p.name = name soup = cleanup_wiki_page(data["content"]) p.content = unicode(soup.body) self.db.add(p) p = self.db.merge(p) return self.serialize_object(p)
def __init__(self, request): super(WikiPageView, self).__init__(request) self.mgr = WikiPageManager(request.trfdb) self.wikicollector = WikiCollector() self.limit = 25