Esempio n. 1
0
 def add_post_comment(self, m):
     with self.factory('rw') as f:
         if not f.posts.add_post_comment(m.slug, m.message):
             return False
         f.session.commit()
     cached.dependency.delete_multi((
         keys.post(m.slug),
         keys.author_comments(self.principal.id)))
     return True
Esempio n. 2
0
 def get(self):
     m = attrdict(slug=u(''), fields=[''])
     if (not self.try_update_model(m, self.route_args) or
             not self.try_update_model(m, self.request.query) or
             not self.validate(m, post_spec_validator)):
         return self.json_errors()
     p = self.get_post(m.slug, m.fields)
     if not p:
         return not_found()
     r = self.json_response(p)
     if self.principal:
         r.cache_dependency = (
             keys.post(m.slug),
             keys.author_comments(self.principal.id))
     else:
         r.cache_dependency = (keys.post_public(m.slug),)
     return r