Example #1
0
 def post(self):
     url = canonical_url(self.request.get('url'))
     source_id = Source.id_for_source(url)
     source = ndb.Key(Source, source_id).get()
     while True:
         articles = Article.query(Article.source == source.key).order(-Article.added_date, Article.added_order).fetch(limit=100, keys_only=True)
         if len(articles) == 0: break
         ndb.delete_multi(articles)
     source.key.delete()
     self.response.write('Done')
Example #2
0
def ensure_source(url, suppress_immediate_fetch=False):
    url = canonical_url(url)
    source_id = Source.id_for_source(url)
    source, inserted = get_or_insert(Source, source_id)
    if inserted:
        source.url = url
        source.put()
        source.enqueue_fetch()
    if inserted and not suppress_immediate_fetch:
        source.fetch_now()
    return source