comparison MoinMoin/items/__init__.py @ 860:de6ece090b7d storage-ng

fix download view
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 25 Sep 2011 01:03:06 +0200
parents 95d1033b7808
children 9a7889c04a25
comparison
equal deleted inserted replaced
859:95d1033b7808 860:de6ece090b7d
700 rename_template = 'rename.html' 700 rename_template = 'rename.html'
701 revert_template = 'revert.html' 701 revert_template = 'revert.html'
702 702
703 def _render_data_diff(self, oldrev, newrev): 703 def _render_data_diff(self, oldrev, newrev):
704 hash_name = HASH_ALGORITHM 704 hash_name = HASH_ALGORITHM
705 if oldrev[hash_name] == newrev[hash_name]: 705 if oldrev.meta[hash_name] == newrev.meta[hash_name]:
706 return _("The items have the same data hash code (that means they very likely have the same data).") 706 return _("The items have the same data hash code (that means they very likely have the same data).")
707 else: 707 else:
708 return _("The items have different data.") 708 return _("The items have different data.")
709 709
710 _render_data_diff_text = _render_data_diff 710 _render_data_diff_text = _render_data_diff
733 file_to_send = self.get_member(member) 733 file_to_send = self.get_member(member)
734 else: # content = item revision 734 else: # content = item revision
735 rev = self.rev 735 rev = self.rev
736 filename = rev.item.name 736 filename = rev.item.name
737 try: 737 try:
738 mimestr = rev[CONTENTTYPE] 738 mimestr = rev.meta[CONTENTTYPE]
739 except KeyError: 739 except KeyError:
740 mt = MimeType(filename=filename) 740 mt = MimeType(filename=filename)
741 else: 741 else:
742 mt = MimeType(mimestr=mimestr) 742 mt = MimeType(mimestr=mimestr)
743 content_length = rev[SIZE] 743 content_length = rev.meta[SIZE]
744 file_to_send = rev 744 file_to_send = rev.data
745 if mimetype: 745 if mimetype:
746 content_type = mimetype 746 content_type = mimetype
747 else: 747 else:
748 content_type = mt.content_type() 748 content_type = mt.content_type()
749 as_attachment = force_attachment or mt.as_attachment(app.cfg) 749 as_attachment = force_attachment or mt.as_attachment(app.cfg)
1017 1017
1018 def _render_data_diff_raw(self, oldrev, newrev): 1018 def _render_data_diff_raw(self, oldrev, newrev):
1019 hash_name = HASH_ALGORITHM 1019 hash_name = HASH_ALGORITHM
1020 cid = cache_key(usage="ImageDiff", 1020 cid = cache_key(usage="ImageDiff",
1021 hash_name=hash_name, 1021 hash_name=hash_name,
1022 hash_old=oldrev[hash_name], 1022 hash_old=oldrev.meta[hash_name],
1023 hash_new=newrev[hash_name]) 1023 hash_new=newrev.meta[hash_name])
1024 c = app.cache.get(cid) 1024 c = app.cache.get(cid)
1025 if c is None: 1025 if c is None:
1026 if PIL is None: 1026 if PIL is None:
1027 abort(404) # TODO render user friendly error image 1027 abort(404) # TODO render user friendly error image
1028 1028
1029 content_type = newrev[CONTENTTYPE] 1029 content_type = newrev.meta[CONTENTTYPE]
1030 if content_type == 'image/jpeg': 1030 if content_type == 'image/jpeg':
1031 output_type = 'JPEG' 1031 output_type = 'JPEG'
1032 elif content_type == 'image/png': 1032 elif content_type == 'image/png':
1033 output_type = 'PNG' 1033 output_type = 'PNG'
1034 elif content_type == 'image/gif': 1034 elif content_type == 'image/gif':