Opened 4 years ago
Last modified 4 years ago
#32850 closed Cleanup/optimization
Sitemap.items() gets called several times: Fix or document? — at Version 4
| Reported by: | Thomas Güttler | Owned by: | nobody |
|---|---|---|---|
| Component: | Documentation | Version: | 3.2 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Ready for checkin | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
The Sitemap.items() method might get called several times (if you generate several pages in batch)
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))
....
@property
def paginator(self):
return paginator.Paginator(self.items(), self.limit)
I see two options now:
Option1: Document this behaviour.
Option2: make paginator a cached_property.
Change History (4)
comment:1 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:2 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:3 by , 4 years ago
| Description: | modified (diff) |
|---|
comment:4 by , 4 years ago
| Description: | modified (diff) |
|---|
Note:
See TracTickets
for help on using tickets.