[Moin-devel] tex

Won Kyu Park wkpark at chem.skku.ac.kr
Sat Aug 10 06:20:02 EDT 2002


Hello,

I make a JME(java molecular editor) enabled action/macro.

http://chem.skku.ac.kr/~wkpark/wiki-1.1/moin.cgi/Tests
(a embeded molecular can be showed with the chemscape)

and I made some patch against action/AttachFile.py

with this patch, you can attach any input as a text input form.

Regards,

Won-kyu Park
-------------- next part --------------
diff -ur -x '*.pyc' moin-1.1/MoinMoin/action/AttachFile.py wiki-1.1/lib/python/MoinMoin/action/AttachFile.py
--- moin-1.1/MoinMoin/action/AttachFile.py	Thu Jul 18 17:00:21 2002
+++ wiki-1.1/lib/python/MoinMoin/action/AttachFile.py	Sat Aug 10 22:31:29 2002
@@ -310,8 +310,16 @@
     
 def do_upload(pagename, request):
     # check file & mimetype
-    fileitem = request.form['file']
-    if not fileitem.file:
+    mode='file'
+    if request.form.has_key('file') and request.form['file']:
+        fileitem = request.form['file']
+        if not fileitem.file:
+           return error_msg(pagename, request,
+            _("<b>Filename of attachment not specified!</b>"))
+    if request.form.has_key('text') and request.form['text']:
+        textitem=request.form['text'].value
+        mode='text'
+    else:
         error_msg(pagename, request,
             _("<b>Filename of attachment not specified!</b>"))
         return
@@ -322,7 +330,11 @@
         filesys.makeDirs(attach_dir)
 
     # make filename
-    filename = fileitem.filename
+    if mode=='file':
+        filename = fileitem.filename
+    else:
+        filename = string.strip(request.form['name'].value)
+
     rename = ''
     if request.form.has_key('rename'):
         rename = string.strip(request.form['rename'].value)
@@ -355,12 +367,20 @@
     if os.path.exists(fpath):
         msg = _("Attachment '%(target)s' (remote name '%(filename)s') already exists.") % locals()
     else:
-        content = fileitem.file.read()
-        stream = open(fpath, 'wb')
-        try:
-            stream.write(content)
-        finally:
-            stream.close()
+        if mode == 'file':
+            content = fileitem.file.read()
+            stream = open(fpath, 'wb')
+            try:
+                stream.write(content)
+            finally:
+                stream.close()
+        else:
+            content = string.strip(textitem)
+            stream = open(fpath, 'w')
+            try:
+                stream.write(content)
+            finally:
+                stream.close()
         os.chmod(fpath, 0666 & config.umask)
 
         bytes = len(content)


More information about the Moin-devel mailing list