# HG changeset patch # User Reimar Bauer # Date 1176130376 0 # Node ID eb5328be394ee7053e71e587c808c0410bb5c77d # Parent efafd0dd3ff84ea098b90cd9e62776f999244d90 AttachFile:destinguish between zip and other fileformats using zip archives diff -r efafd0dd3ff8 -r eb5328be394e MoinMoin/action/AttachFile.py --- a/MoinMoin/action/AttachFile.py Mon Apr 09 10:40:47 2007 +0000 +++ b/MoinMoin/action/AttachFile.py Mon Apr 09 14:52:56 2007 +0000 @@ -305,6 +305,7 @@ label_install = _("install") for file in files: + mt = wikiutil.MimeType(filename=file) st = os.stat(os.path.join(attach_dir, file).encode(config.charset)) fsize = "%.1f" % (float(st.st_size) / 1024) fmtime = request.user.getFormattedDateTime(st.st_mtime) @@ -342,11 +343,11 @@ else: viewlink = '%(label_view)s' % parmdict - if (packages.ZipPackage(request, os.path.join(attach_dir, file).encode(config.charset)).isPackage() and + if (packages.ZipPackage(request, os.path.join(attach_dir, file).encode(config.charset)).isPackage() and mt.minor == 'zip' and request.user.isSuperUser()): viewlink += ' | %(label_install)s' % parmdict elif (zipfile.is_zipfile(os.path.join(attach_dir, file).encode(config.charset)) and - request.user.may.read(pagename) and request.user.may.delete(pagename) + mt.minor == 'zip' and request.user.may.read(pagename) and request.user.may.delete(pagename) and request.user.may.write(pagename)): viewlink += ' | %(label_unzip)s' % parmdict @@ -990,11 +991,11 @@ return package = packages.ZipPackage(request, fpath) - if package.isPackage(): + if package.isPackage() and mt.minor == 'zip': request.write("
%s\n%s
" % (_("Package script:"), wikiutil.escape(package.getScript()))) return - if zipfile.is_zipfile(fpath): + if zipfile.is_zipfile(fpath) and mt.minor == 'zip': zf = zipfile.ZipFile(fpath, mode='r') request.write("
%-46s %19s %12s\n" % (_("File Name"), _("Modified")+" "*5, _("Size")))
         for zinfo in zf.filelist: