equal
deleted
inserted
replaced
1 # copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
1 # copyright 2003-2013 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
2 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr |
3 # |
3 # |
4 # This file is part of CubicWeb. |
4 # This file is part of CubicWeb. |
5 # |
5 # |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
6 # CubicWeb is free software: you can redistribute it and/or modify it under the |
18 """Set of static resources controllers for : |
18 """Set of static resources controllers for : |
19 |
19 |
20 - /data/... |
20 - /data/... |
21 - /static/... |
21 - /static/... |
22 - /fckeditor/... |
22 - /fckeditor/... |
23 |
|
24 """ |
23 """ |
25 |
24 |
26 import os |
25 import os |
27 import os.path as osp |
26 import os.path as osp |
28 import hashlib |
27 import hashlib |
76 # Note that: we do a osp.isdir + osp.isfile before and a potential |
75 # Note that: we do a osp.isdir + osp.isfile before and a potential |
77 # os.read after. Improving this specific call will not help |
76 # os.read after. Improving this specific call will not help |
78 # |
77 # |
79 # Real production environment should use dedicated static file serving. |
78 # Real production environment should use dedicated static file serving. |
80 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
79 self._cw.set_header('last-modified', generateDateTime(os.stat(path).st_mtime)) |
81 self._cw.validate_cache() |
80 if self._cw.is_client_cache_valid(): |
|
81 return '' |
82 # XXX elif uri.startswith('/https/'): uri = uri[6:] |
82 # XXX elif uri.startswith('/https/'): uri = uri[6:] |
83 mimetype, encoding = mimetypes.guess_type(path) |
83 mimetype, encoding = mimetypes.guess_type(path) |
84 if mimetype is None: |
84 if mimetype is None: |
85 mimetype = 'application/octet-stream' |
85 mimetype = 'application/octet-stream' |
86 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |
86 self._cw.set_content_type(mimetype, osp.basename(path), encoding) |