def get(self, kind): if kind not in ['elements', 'collections', 'authors']: self.response.set_status(404) return sitemap = Sitemap.get_by_id(kind) if sitemap is None: self.response.set_status(404) return prefix = { 'elements': '/element/', 'collections': '/collection/', 'authors': '/author/', }[kind] parsed_url = urlparse(self.request.url) host = '%s://%s' % (parsed_url.scheme, parsed_url.netloc) self.response.headers['Content-Type'] = 'text/plain' self.response.write('\n'.join(['%s%s%s' % (host, prefix, page) for page in sitemap.pages]))
def handle_get(self): keys = (Library.query() .filter(Library.kind == 'element') # pylint: disable=singleton-comparison .filter(Library.shallow_ingestion == False) .filter(Library.status == Status.ready) .fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY)) elements = Sitemap(id='elements') elements.pages = [key.id() for key in keys] elements.put() logging.info('%d elements', len(elements.pages)) keys = (Library.query() .filter(Library.kind == 'collection') # pylint: disable=singleton-comparison .filter(Library.shallow_ingestion == False) .filter(Library.status == Status.ready) .fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY)) collections = Sitemap(id='collections') collections.pages = [key.id() for key in keys] collections.put() logging.info('%d collections', len(collections.pages)) keys = Author.query().fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY) authors = Sitemap(id='authors') authors.pages = [key.id() for key in keys] authors.put() logging.info('%d authors', len(authors.pages))
def handle_get(self): keys = ( Library.query().filter(Library.kind == 'element') # pylint: disable=singleton-comparison .filter(Library.shallow_ingestion == False).filter( Library.status == Status.ready).fetch( keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY)) elements = Sitemap(id='elements') elements.pages = [key.id() for key in keys] elements.put() logging.info('%d elements', len(elements.pages)) keys = ( Library.query().filter(Library.kind == 'collection') # pylint: disable=singleton-comparison .filter(Library.shallow_ingestion == False).filter( Library.status == Status.ready).fetch( keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY)) collections = Sitemap(id='collections') collections.pages = [key.id() for key in keys] collections.put() logging.info('%d collections', len(collections.pages)) keys = Author.query().fetch(keys_only=True, read_policy=ndb.EVENTUAL_CONSISTENCY) authors = Sitemap(id='authors') authors.pages = [key.id() for key in keys] authors.put() logging.info('%d authors', len(authors.pages))