web/views/idownloadable.py
changeset 5868 c4380d8cfc25
parent 5714 04a8e48f10bc
parent 5866 e676a869a3e9
child 5877 0c7b7b76a84f
--- a/web/views/idownloadable.py	Fri Jul 02 11:52:51 2010 +0200
+++ b/web/views/idownloadable.py	Fri Jul 02 14:47:44 2010 +0200
@@ -26,7 +26,7 @@
 from cubicweb.selectors import (one_line_rset, implements, match_context_prop,
                                 adaptable, has_mimetype)
 from cubicweb.mttransforms import ENGINE
-from cubicweb.web.box import EntityBoxTemplate
+from cubicweb.web import box, httpcache
 from cubicweb.web.views import primary, baseviews
 
 
@@ -46,7 +46,7 @@
     w(u'</div></div>\n')
 
 
-class DownloadBox(EntityBoxTemplate):
+class DownloadBox(box.EntityBoxTemplate):
     __regid__ = 'download_box'
     # no download box for images
     # XXX primary_view selector ?
@@ -69,6 +69,7 @@
     templatable = False
     content_type = 'application/octet-stream'
     binary = True
+    http_cache_manager = httpcache.EntityHTTPCacheManager
     add_to_breadcrumbs = False
 
     def set_request_content_type(self):
@@ -90,6 +91,8 @@
         adapter = entity.cw_adapt_to('IDownloadable')
         self.w(adapter.download_data())
 
+    def last_modified(self):
+        return self.cw_rset.get_entity(self.cw_row or 0, self.cw_col or 0).modification_date
 
 class DownloadLinkView(EntityView):
     """view displaying a link to download the file"""