#32850: Sitemap.items() gets called several times: Fix or document?
--------------------------------+--------------------------------------
Reporter: Thomas Güttler | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 3.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------------------------
Description changed by Thomas Güttler:
Old description:
> The
> [https://docs.djangoproject.com/en/3.2/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.items
> Sitemap.items()] method gets called several times.
>
> This is confusing and might waste computation resources.
>
> ```
> def _urls(self, page, protocol, domain):
> urls = []
> latest_lastmod = None
> all_items_lastmod = True # track if all items have a lastmod
> for item in self.paginator.page(page).object_list:
> loc = "%s://%s%s" % (protocol, domain, self.__get('location',
> item))
> ....
> ```
>
> I see two options now:
>
> Option1: Document this behaviour.
>
> Option2: make paginator a cached_property.
New description:
The
[https://docs.djangoproject.com/en/3.2/ref/contrib/sitemaps/#django.contrib.sitemaps.Sitemap.items
Sitemap.items()] method gets called several times.
This is confusing and might waste computation resources.
{{{
def _urls(self, page, protocol, domain):
urls = []
latest_lastmod = None
all_items_lastmod = True # track if all items have a lastmod
for item in self.paginator.page(page).object_list:
loc = "%s://%s%s" % (protocol, domain, self.__get('location',
item))
....
}}}
I see two options now:
Option1: Document this behaviour.
Option2: make paginator a cached_property.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32850#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.06bf49d923c63de3cf69f56907c59462%40djangoproject.com.