[cvs-annodex] commit (/annodex): cmmlwiki/trunk/cgi-bin/edit.cgi

conrad nobody at lists.annodex.net
Mon Nov 21 13:15:57 EST 2005


Update of /annodex (new revision 1646)

Modified files:
   cmmlwiki/trunk/cgi-bin/edit.cgi

Log Message:
add API: handling to edit.cgi


Modified: cmmlwiki/trunk/cgi-bin/edit.cgi
===================================================================
--- cmmlwiki/trunk/cgi-bin/edit.cgi	2005-11-21 02:00:54 UTC (rev 1645)
+++ cmmlwiki/trunk/cgi-bin/edit.cgi	2005-11-21 02:15:57 UTC (rev 1646)
@@ -8,9 +8,36 @@
 import os
 import cgi
 from string import split
+import sys
 
+from cmmlwiki.autocomplete import auto_complete_items
 from cmmlwiki.handler import Handler
+from cmmlwiki.inplace import update_clip, update_head
 
+def handle_api (handler, proc, path_bits):
+
+    sys.stderr.write ('update %s' % (proc))
+
+    if (handler.form.has_key("value")):
+        try:
+            iname = path_bits[1]
+            ixi = handler.inspector.iname2ixi (iname)
+            ixc = path_bits[2]
+            field = path_bits[3]
+        except TypeError:
+            ixi = -1
+
+    if (proc == 'UpdateClip'):
+        update_clip (ixi, ixc, field, handler.form['value'].value)
+    elif (proc == 'UpdateHead'):
+        update_head (ixi, field, handler.form['value'].value)
+
+    elif (proc == 'ListItems'):
+        auto_complete_items (handler.inspector, handler.form[''].value)
+
+    else:
+        handler.error ("Invalid procedure %s" % (proc))
+
 def handle_special (handler, command):
     if (command == "ListAllItems"):
         handler.list_all_items ()
@@ -19,6 +46,11 @@
 
 def handle_iname (handler, ext, action):
 
+    if (os.environ.has_key("HTTP_ACCEPT")):
+        accept = os.environ["HTTP_ACCEPT"]
+    else:
+        accept = ""
+
     if (ext == ".axv"):
       if (accept == "text/x-cmml"):
           handler.dump_cmml()
@@ -68,7 +100,8 @@
     else:
         try:
             # Strip leading '/' from PATH_INFO, split off extension
-            s = os.path.splitext(path_info[1:])
+            path_bits = split (path_info[1:], '/')
+            s = os.path.splitext(path_bits[0])
             wikiname = s[0]
             ext = s[1]
         except TypeError:
@@ -80,15 +113,12 @@
         except KeyError:
             action = "toc"
 
-    if (os.environ.has_key("HTTP_ACCEPT")):
-        accept = os.environ["HTTP_ACCEPT"]
-    else:
-        accept = ""
-
     handler = Handler (wikiname, form)
     wikibits = split (wikiname, ':')
 
-    if (wikibits[0] == 'Special'):
+    if (wikibits[0] == 'API'):
+        handle_api (handler, wikibits[1], path_bits)
+    elif (wikibits[0] == 'Special'):
         handle_special (handler, wikibits[1])
     else:
         handle_iname (handler, ext, action)


-- 
conrad



More information about the cvs-annodex mailing list