diff MoinMoin/action/AttachFile.py @ 281:8155e50e94ca

fixed crash with non-ASCII attachment filename imported from: moin--main--1.5--patch-285
author Thomas Waldmann <tw@waldmann-edv.de>
date Sun, 04 Dec 2005 11:40:42 +0000
parents 015c945277ec
children d9028858980d
line wrap: on
line diff
--- a/MoinMoin/action/AttachFile.py	Sun Dec 04 10:34:44 2005 +0000
+++ b/MoinMoin/action/AttachFile.py	Sun Dec 04 11:40:42 2005 +0000
@@ -66,11 +66,14 @@
     return attach_dir
 
 def absoluteName(url, pagename):
-    """ Get (pagename, filename) of an atatchment: link
+    """ Get (pagename, filename) of an attachment: link
+        @param url: PageName/filename.ext or filename.ext (unicode)
+        @param pagename: name of the currently processed page (unicode)
+        @rtype: tuple of unicode
+        @return: PageName, filename.ext
     """
-
-    pieces = url.split('/')
-    if len(pieces)==1:
+    pieces = url.split(u'/')
+    if len(pieces) == 1:
         return pagename, pieces[0]
     else:
         return u"/".join(pieces[:-1]), pieces[-1]
@@ -123,8 +126,15 @@
     return attach_link
 
 
-def getFilename(request, pagename, name):
-    return os.path.join(getAttachDir(request, pagename), name).encode(config.charset)
+def getFilename(request, pagename, filename):
+    """ make complete pathfilename of file "name" attached to some page "pagename"
+        @param request: request object
+        @param pagename: name of page where the file is attached to (unicode)
+        @param filename: filename of attached file (unicode)
+        @rtype: string (in config.charset encoding)
+        @return: complete path/filename of attached file
+    """
+    return os.path.join(getAttachDir(request, pagename), filename).encode(config.charset)
 
 
 def info(pagename, request):