Index: openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql,v
diff -u -r1.37 -r1.38
--- openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql	14 Feb 2003 02:47:13 -0000	1.37
+++ openacs-4/packages/acs-kernel/sql/postgresql/acs-objects-create.sql	17 Feb 2003 15:32:53 -0000	1.38
@@ -382,8 +382,6 @@
    where object_id != ancestor_id;
 
 create function acs_objects_context_id_in_tr () returns opaque as '
-declare
-        security_context_root integer;
 begin
   insert into acs_object_context_index
    (object_id, ancestor_id, n_generations)
@@ -398,15 +396,13 @@
      n_generations + 1 as n_generations
     from acs_object_context_index
     where object_id = new.context_id;
-  else
-    security_context_root = acs__magic_object_id(''security_context_root'');
-    if new.object_id != security_context_root then
-      insert into acs_object_context_index
-        (object_id, ancestor_id, n_generations)
-      values
-        (new.object_id, security_context_root, 1);
-    end if;
-  end if;
+  else if new.object_id != 0 then
+    -- 0 is the id of the security context root object
+    insert into acs_object_context_index
+     (object_id, ancestor_id, n_generations)
+    values
+     (new.object_id, 0, 1);
+  end if; end if;
 
   return new;
 
@@ -420,7 +416,6 @@
 create function acs_objects_context_id_up_tr () returns opaque as '
 declare
         pair    record;
-        security_context_root integer;
 begin
   if new.object_id = old.object_id and
      new.context_id = old.context_id and
@@ -460,22 +455,19 @@
       from acs_object_context_index
       where object_id = new.context_id;
     end loop;
-  else
-    security_context_root = acs__magic_object_id(''security_context_root'');
-    if new.object_id != security_context_root then
+  else if new.object_id != 0 then
     -- We need to make sure that new.OBJECT_ID and all of its
-    -- children have security_context_root as an ancestor.
+    -- children have 0 as an ancestor.
     for pair in  select *
 		 from acs_object_context_index
 		 where ancestor_id = new.object_id 
-      LOOP
-        insert into acs_object_context_index
-         (object_id, ancestor_id, n_generations)
-        values
-         (pair.object_id, security_context_root, pair.n_generations + 1);
-      end loop;
-    end if;
-  end if;
+    LOOP
+      insert into acs_object_context_index
+       (object_id, ancestor_id, n_generations)
+      values
+       (pair.object_id, 0, pair.n_generations + 1);
+    end loop;
+  end if; end if;
 
   return new;
 
