def callback(): s = site.key.get() s.publish = None if not s.publish: p = models.Publish(parent=site.key) p.manifest = s.generate_manifest() p.put() s.publish = p.key s.put() deferred.defer(publish_site, sitename)
def delete(self, source_url): """Attempts to delete or preview delete a published post. Args: source_url: string, original post URL Returns: dict response data with at least id and url """ self.entity = self.get_or_add_publish_entity(source_url) if not self.entity: return None if ((self.entity.status != 'complete' or self.entity.type == 'preview') and not appengine_info.LOCAL): return self.error( "Can't delete this post from %s because Bridgy Publish didn't originally POSSE it there" % self.source.gr_source.NAME) id = self.entity.published.get('id') url = self.entity.published.get('url') if not id and url: id = self.source.gr_source.post_id(url) if not id: return self.error( "Bridgy Publish can't find the id of the %s post that it originally published for %s" % self.source.gr_source.NAME, source_url) if self.PREVIEW: try: return self._render_preview( self.source.gr_source.preview_delete(id)) except NotImplementedError: return self.error( "Sorry, deleting isn't supported for %s yet" % self.source.gr_source.NAME) logging.info('Deleting silo post id %s', id) self.entity = models.Publish(parent=self.entity.key.parent(), source=self.source.key, type='delete') self.entity.put() logging.debug("Publish entity for delete: '%s'", self.entity.key.urlsafe().decode()) resp = self.source.gr_source.delete(id) resp.content.setdefault('id', id) resp.content.setdefault('url', url) logging.info(resp.content) self.entity.published = resp.content self.entity.status = 'deleted' self.entity.put() return resp