# This is a patch for moin-1.2.3.orig to update it to moin-1.2.3
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# If you have a decent Bourne-type shell:
# STEP 2: Run the shell with this file as input.
# If you don't have such a shell, you may need to manually create
# the files as shown below.
# STEP 3: Run the 'patch' program with this file as input.
#
# These are the commands needed to create/delete files/directories:
#
touch 'MoinMoin/macro/AttachInfo.py'
chmod 0664 'MoinMoin/macro/AttachInfo.py'
touch 'MoinMoin/macro/AttachList.py'
chmod 0664 'MoinMoin/macro/AttachList.py'
#
# This command terminates the shell and need not be executed manually.
exit
#
#### End of Preamble ####

#### Patch data follows ####
diff -u 'moin-1.2.3.orig/MoinMoin/action/AttachFile.py' 'moin-1.2.3/MoinMoin/action/AttachFile.py'
Index: ./MoinMoin/action/AttachFile.py
--- ./MoinMoin/action/AttachFile.py	Wed Jul 21 21:02:15 2004
+++ ./MoinMoin/action/AttachFile.py	Thu Sep 23 12:45:11 2004
@@ -124,7 +124,7 @@
         'count': len(files),
         'link': Page(pagename).url(request, "action=AttachFile")
     }
-    request.write("\n<p>\n%s\n</p>\n" % attach_info)
+    return "\n<p>\n%s\n</p>\n" % attach_info
 
 
 #############################################################################
@@ -165,7 +165,7 @@
     return (None, None)
 
 
-def _get_filelist(request, pagename):
+def _build_filelist(request, pagename, showheader, readonly):
     _ = request.getText
 
     # access directory
@@ -177,12 +177,13 @@
 
     str = ""
     if files:
-        str = str + _("<p>"
-            "To refer to attachments on a page, use <strong><tt>attachment:filename</tt></strong>, \n"
-            "as shown below in the list of files. \n"
-            "Do <strong>NOT</strong> use the URL of the <tt>[get]</tt> link, \n"
-            "since this is subject to change and can break easily.</p>"
-        )
+        if showheader:
+            str = str + _("<p>"
+                          "To refer to attachments on a page, use <strong><tt>attachment:filename</tt></strong>, \n"
+                          "as shown below in the list of files. \n"
+                          "Do <strong>NOT</strong> use the URL of the <tt>[get]</tt> link, \n"
+                          "since this is subject to change and can break easily.</p>"
+                          )
         str = str + "<ul>"
 
         label_del = _("del")
@@ -209,7 +210,7 @@
                         'pagename': pagename}
             
             del_link = ''
-            if request.user.may.delete(pagename):
+            if request.user.may.delete(pagename) and not readonly:
                 del_link = '<a href="%(baseurl)s/%(urlpagename)s' \
                     '?action=%(action)s&amp;do=del&amp;target=%(urlfile)s">%(label_del)s</a>&nbsp;| ' % parmdict
 
@@ -225,11 +226,16 @@
                 ' (%(fsize)g KB) attachment:<strong>%(file)s</strong></li>') % parmdict
         str = str + "</ul>"
     else:
-        str = '%s<p>%s</p>' % (str, _("No attachments stored for %(pagename)s") % {'pagename': pagename})
+        if showheader:
+            str = '%s<p>%s</p>' % (str, _("No attachments stored for %(pagename)s") % {'pagename': pagename})
 
     return str
-        
-    
+
+
+def _get_filelist(request, pagename):
+    return _build_filelist(request, pagename, 1, 0)
+
+
 def error_msg(pagename, request, msg):
     Page(pagename).send_page(request, msg=msg)
 
diff -u /dev/null 'moin-1.2.3/MoinMoin/macro/AttachInfo.py'
Index: ./MoinMoin/macro/AttachInfo.py
--- ./MoinMoin/macro/AttachInfo.py	Thu Jan  1 01:00:00 1970
+++ ./MoinMoin/macro/AttachInfo.py	Thu Sep 23 12:43:42 2004
@@ -0,0 +1,20 @@
+"""
+    MoinMoin - AttachList Macro
+
+    Written by Jacob Cohen.
+    Rehashed & renamed by Nigel Metheringham
+
+    A macro to produce information about attached pages
+
+    Usage: [[AttachInfo]]
+
+"""
+
+from MoinMoin.action.AttachFile import info
+
+def execute(macro, args):
+    pagename = macro.formatter.page.page_name
+    if args:
+        pagename = args
+    result = info(pagename, macro.request);
+    return result
diff -u /dev/null 'moin-1.2.3/MoinMoin/macro/AttachList.py'
Index: ./MoinMoin/macro/AttachList.py
--- ./MoinMoin/macro/AttachList.py	Thu Jan  1 01:00:00 1970
+++ ./MoinMoin/macro/AttachList.py	Thu Sep 23 12:43:40 2004
@@ -0,0 +1,20 @@
+"""
+    MoinMoin - AttachList Macro
+
+    Written by Jacob Cohen.
+    Rehashed & renamed by Nigel Metheringham
+
+    A macro to produce a list of attached pages
+
+    Usage: [[AttachList]]
+
+"""
+
+from MoinMoin.action.AttachFile import _build_filelist
+
+def execute(macro, args):
+    pagename = macro.formatter.page.page_name
+    if args:
+        pagename = args
+    result = _build_filelist(macro.request, pagename, 0, 1);
+    return result
diff -u 'moin-1.2.3.orig/MoinMoin/wikiaction.py' 'moin-1.2.3/MoinMoin/wikiaction.py'
Index: ./MoinMoin/wikiaction.py
--- ./MoinMoin/wikiaction.py	Wed Jul 21 21:02:16 2004
+++ ./MoinMoin/wikiaction.py	Thu Sep 23 12:45:17 2004
@@ -348,7 +348,8 @@
 
         # show attachments (if allowed)
         attachment_info = getHandler('AttachFile', 'info')
-        if attachment_info: attachment_info(pagename, request)
+        if attachment_info:
+            request.write(attachment_info(pagename, request))
 
         # show subscribers
         subscribers = page.getSubscribers(request,  include_self=1, return_users=1)
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Thu Sep 23 12:45:24 2004
# Generated by        : makepatch 2.00_07*
# Recurse directories : Yes
# Excluded files      : (\A|/).*\~\Z
#                       (\A|/).*\.a\Z
#                       (\A|/).*\.bak\Z
#                       (\A|/).*\.BAK\Z
#                       (\A|/).*\.elc\Z
#                       (\A|/).*\.exe\Z
#                       (\A|/).*\.gz\Z
#                       (\A|/).*\.ln\Z
#                       (\A|/).*\.o\Z
#                       (\A|/).*\.obj\Z
#                       (\A|/).*\.olb\Z
#                       (\A|/).*\.old\Z
#                       (\A|/).*\.orig\Z
#                       (\A|/).*\.rej\Z
#                       (\A|/).*\.so\Z
#                       (\A|/).*\.Z\Z
#                       (\A|/)\.del\-.*\Z
#                       (\A|/)\.make\.state\Z
#                       (\A|/)\.nse_depinfo\Z
#                       (\A|/)core\Z
#                       (\A|/)tags\Z
#                       (\A|/)TAGS\Z
#                       (\A|/)\.\#.*\Z
#                       (\A|/)\#.*\Z
#                       (\A|/)_\$.*\Z
#                       (\A|/).*\$\Z
#                       (\A|/)CVS\Z
#                       (\A|/)CVS\.adm\Z
#                       (\A|/)cvslog\..*\Z
#                       (\A|/)\,.*\Z
#                       (\A|/).*\,v\Z
#                       (\A|/)RCS\Z
#                       (\A|/)RCSLOG\Z
#                       (\A|/)p\..*\Z
#                       (\A|/)s\..*\Z
#                       (\A|/)SCCS\Z
# p 'MoinMoin/action/AttachFile.py' 22090 1095939911 0100644
# c 'MoinMoin/macro/AttachInfo.py' 0 1095939822 0100664
# c 'MoinMoin/macro/AttachList.py' 0 1095939820 0100664
# p 'MoinMoin/wikiaction.py' 32803 1095939917 0100644
#### End of ApplyPatch data ####

#### End of Patch kit [created: Thu Sep 23 12:45:24 2004] ####
#### Patch checksum: 186 6673 729 ####
#### Checksum: 218 7851 35037 ####
