I recently discovered that object attributes in CherryPy persist between requests (and between clients). So I wonder if it makes sense to store page output in such an attribute? Like this:
class Page: def default(self, pagenumber): if pagenumber not in self.validpages: return 'Page number not found' try: html = self.pageoutput[pagenumber] except KeyError: html = self.formatter(self.dbcall(pagenumber)) return html default.exposed = True def formatter(self, data): html =
I know that CherryPy caches GET requests by default. In my tests, when an attribute of an object was part of the result and this attribute was changed, CherryPy served the attribute of the new value. Does this mean that the output was partially cached?
For me, this would be useful if you would update self.pageoutput every time you change the database. The only difficulty I could imagine was if I wanted to display user information. What do you think?
source share