def blog_page_changed(thepage): batch = PurgeBatch() for blog_index in BlogIndexPage.objects.live(): if thepage in blog_index.get_blog_items().object_list: batch.add_page(blog_index) batch.purge()
def event_page_changed(event_page): logger.info('Checking for index pages containing {}'.format(event_page)) # Find all the live EventIndexPages that contain this event_page batch = PurgeBatch() for event_index in EventIndexPage.objects.live(): logger.info('Checking if event_page is in {}'.format(event_index)) # The Paginator returns a list of Page class objects which won't match with our event_page object of class # EventPage, we need to get convert the list to EventPages by calling their specific attribute first pages = event_index.get_event_items().object_list event_items = [page.specific for page in pages] if event_page in event_items: logger.info(f'Adding {event_index} to purge list') batch.add_page(event_index) # Purge all the event indexes we found in a single request logger.info('Purging!') batch.purge()
def general_page_changed(general_page): logger.info('Checking for index pages containing {}'.format(general_page)) # Find all the live GeneralIndexPages that contain this general_page batch = PurgeBatch() for general_index in GeneralIndexPage.objects.live(): logger.info('Checking if general_page is in {}'.format(general_index)) # The Paginator returns a list of Page class objects which won't match with our general_page object of class # GeneralPage or TwoColumnGeneralPage, we need to get convert the list to EventPages by calling their specific # attribute first pages = general_index.get_general_items().object_list general_items = [page.specific for page in pages] if general_page in general_items: logger.info('Adding general_index to purge list') batch.add_page(general_index) # Purge all the event indexes we found in a single request logger.info('Purging!') batch.purge()
def product_page_changed(product_page): logger.info( 'Checking for shop index pages containing {}'.format(product_page)) # Find all the live ShopIndexPages that contain this product_page batch = PurgeBatch() for shop_index in ShopIndexPage.objects.live(): logger.info('Checking if product_page is in {}'.format(shop_index)) # The Paginator returns a list of Page class objects which won't match with our product_page object of class # Product so we need to get convert the list to Products by calling their specific # attribute first pages = shop_index.get_product_items().object_list product_items = [page.specific for page in pages] if product_page in product_items: logger.info('Adding shop_index to purge list') batch.add_page(shop_index) # Purge all the shop indexes we found in a single request logger.info('Purging!') batch.purge()
def blog_page_changed(blog_page): batch = PurgeBatch() for index in BlogIndex.objects.live().ancestor_of(blog_page): batch.add_page(index) batch.purge()
def photo_page_changed(photo_page): batch = PurgeBatch() for index in PhotoIndex.objects.live().ancestor_of(photo_page): batch.add_page(index) batch.purge()