[cvs-annodex] commit (/annodex): cmmlwiki/trunk/cmmlwiki/item.py

conrad nobody at lists.annodex.net
Wed Oct 5 16:42:42 EST 2005


Update of /annodex (new revision 1558)

Modified files:
   cmmlwiki/trunk/cmmlwiki/item.py

Log Message:
fix up deletion of heads etc. when items are deleted


Modified: cmmlwiki/trunk/cmmlwiki/item.py
===================================================================
--- cmmlwiki/trunk/cmmlwiki/item.py	2005-10-05 06:31:25 UTC (rev 1557)
+++ cmmlwiki/trunk/cmmlwiki/item.py	2005-10-05 06:42:42 UTC (rev 1558)
@@ -41,6 +41,8 @@
     con = sqlite.connect(db, encoding='utf-8', autocommit=1)
     cur = con.cursor()
 
+    # ixi = ixi2iname(iname)
+
     sql = 'SELECT * FROM items WHERE name="%s"' % (iname)
     cur.execute(sql)
 
@@ -52,15 +54,44 @@
     vals = {}
     vals['ixi'] = row['ixi']
 
-    sql = 'DELETE FROM items WHERE ixi="%(ixi)s"'
+    # Delete source
+    # XXX: Actually delete the source, if in cmmlwiki/media storage?
+    sql = """DELETE FROM sources
+             WHERE ixs IN (
+               SELECT ixs FROM item_sources
+               WHERE ixi="%(ixi)s"
+             )
+          """
     cur.execute (sql, vals)
 
-    ## Trigger this
-    #sql = 'DELETE FROM sources WHERE ixi="%(ixi)s"'
-    #cur.execute (sql, vals)
-
     sql = 'DELETE FROM item_sources WHERE ixi="%(ixi)s"'
     cur.execute (sql, vals)
 
+    # Delete clips
+    sql = """DELETE FROM clips
+             WHERE ixc IN (
+               SELECT ixc FROM item_clips
+               WHERE ixi="%(ixi)s"
+             )
+          """
+    cur.execute (sql, vals)
+
     sql = 'DELETE FROM item_clips WHERE ixi="%(ixi)s"'
     cur.execute (sql, vals)
+
+    # Delete head
+    sql = """DELETE FROM heads
+             WHERE ixh IN (
+               SELECT ixh FROM item_heads
+               WHERE ixi="%(ixi)s"
+             )
+          """
+    cur.execute (sql, vals)
+
+    sql = 'DELETE FROM item_heads WHERE ixi="%(ixi)s"'
+    cur.execute (sql, vals)
+
+    # Delete item
+    sql = 'DELETE FROM items WHERE ixi="%(ixi)s"'
+    cur.execute (sql, vals)
+


-- 
conrad



More information about the cvs-annodex mailing list