comparison MoinMoin/action/AttachFile.py @ 4226:b2df0c84140f

Fixed handling of if_modified headers (threw exception on attachment-get)
author Florian Krupicka <florian.krupicka@googlemail.com>
date Wed, 16 Jul 2008 17:23:21 +0200
parents f77469d98cd2
children a29fd3a9e91f
comparison
equal deleted inserted replaced
4225:54b6f63ae411 4226:b2df0c84140f
25 2005-2007 MoinMoin:ReimarBauer, 25 2005-2007 MoinMoin:ReimarBauer,
26 2007-2008 MoinMoin:ThomasWaldmann 26 2007-2008 MoinMoin:ThomasWaldmann
27 @license: GNU GPL, see COPYING for details. 27 @license: GNU GPL, see COPYING for details.
28 """ 28 """
29 29
30 import os, time, zipfile, mimetypes, errno 30 import os, time, zipfile, mimetypes, errno, datetime
31 31
32 from MoinMoin import log 32 from MoinMoin import log
33 logging = log.getLogger(__name__) 33 logging = log.getLogger(__name__)
34 34
35 from MoinMoin import config, wikiutil, packages 35 from MoinMoin import config, wikiutil, packages
789 if not request.user.may.read(pagename): 789 if not request.user.may.read(pagename):
790 return _('You are not allowed to get attachments from this page.') 790 return _('You are not allowed to get attachments from this page.')
791 if not filename: 791 if not filename:
792 return # error msg already sent in _access_file 792 return # error msg already sent in _access_file
793 793
794 timestamp = os.path.getmtime(fpath) 794 timestamp = datetime.datetime.fromtimestamp(os.path.getmtime(fpath))
795 if_modified = time.mktime(request.if_modified_since.timetuple()) 795 if_modified = request.if_modified_since
796 if if_modified >= timestamp: 796 if if_modified and if_modified >= timestamp:
797 request.status_code = 304 797 request.status_code = 304
798 else: 798 else:
799 mt = wikiutil.MimeType(filename=filename) 799 mt = wikiutil.MimeType(filename=filename)
800 content_type = mt.content_type() 800 content_type = mt.content_type()
801 mime_type = mt.mime_type() 801 mime_type = mt.mime_type()