Add last_modified and last_modified_id to StorableObject
* qommon/storage.py: those methods can be used to help user-agent caching of page depending solely upon the content of a type of objects, like much of the admin pages.
This commit is contained in:
parent
be0cad4fcb
commit
00ca3f0b24
|
@ -330,3 +330,13 @@ class StorableObject(object):
|
|||
def remove_self(self):
|
||||
self.remove_object(self.id)
|
||||
|
||||
def last_modified_id(cls, id):
|
||||
filename = os.path.join(cls.get_objects_dir(), fix_key(id))
|
||||
stat = os.stat(filename)
|
||||
return stat.st_mtime
|
||||
last_modified_id = classmethod(last_modified_id)
|
||||
|
||||
def last_modified(cls):
|
||||
stat = os.stat(cls.get_objects_dir)
|
||||
return stat.st_mtime
|
||||
last_modified = classmethod(last_modified)
|
||||
|
|
Loading…
Reference in New Issue