Index: openacs-4/packages/acs-admin/acs-admin.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/acs-admin/acs-admin.info,v
diff -u -r1.58.2.1 -r1.58.2.2
--- openacs-4/packages/acs-admin/acs-admin.info	17 May 2019 19:28:06 -0000	1.58.2.1
+++ openacs-4/packages/acs-admin/acs-admin.info	14 Feb 2020 13:42:12 -0000	1.58.2.2
@@ -9,7 +9,7 @@
     <implements-subsite-p>f</implements-subsite-p>
     <inherit-templates-p>t</inherit-templates-p>
 
-    <version name="5.10.0d8" url="http://openacs.org/repository/download/apm/acs-admin-5.10.0d8.apm">
+    <version name="5.10.0d9" url="http://openacs.org/repository/download/apm/acs-admin-5.10.0d9.apm">
         <owner url="mailto:dhogaza@pacifier.com">Don Baccus</owner>
         <summary>An interface for Site-wide administration of an OpenACS Installation.</summary>
         <release-date>2017-08-06</release-date>
@@ -20,7 +20,7 @@
         <license>GPL</license>
         <maturity>3</maturity>
 
-        <provides url="acs-admin" version="5.10.0d8"/>
+        <provides url="acs-admin" version="5.10.0d9"/>
         <requires url="acs-kernel" version="5.9.1"/>
 	<requires url="acs-tcl" version="5.10.0d14"/>
 	<requires url="acs-templating" version="5.9.1"/>
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/acs-admin/tcl/site-wide-procs.tcl'.
Fisheye: No comparison available.  Pass `N' to diff?
Index: openacs-4/packages/xotcl-core/xotcl-core.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/xotcl-core.info,v
diff -u -r1.106.2.11 -r1.106.2.12
--- openacs-4/packages/xotcl-core/xotcl-core.info	3 Feb 2020 22:19:28 -0000	1.106.2.11
+++ openacs-4/packages/xotcl-core/xotcl-core.info	14 Feb 2020 13:42:12 -0000	1.106.2.12
@@ -10,7 +10,7 @@
     <inherit-templates-p>t</inherit-templates-p>
     <auto-mount>xotcl</auto-mount>
 
-    <version name="5.10.0d23" url="http://media.wu-wien.ac.at/download/xotcl-core-5.10.0d23.apm">
+    <version name="5.10.0d24" url="http://media.wu-wien.ac.at/download/xotcl-core-5.10.0d24.apm">
         <owner url="mailto:neumann@wu-wien.ac.at">Gustaf Neumann</owner>
         <summary>XOTcl library functionality (e.g. thread handling, online documentation, Generic Form and List Classes)</summary>
         <release-date>2017-08-06</release-date>
@@ -33,7 +33,7 @@
 - object life-time support (automatic cleanup when needed after request)
 - proxy objects for stored procedures/functions (PostgreSQL and
   Oracle)
-- db-abstraction for PostgreSQL and Oracle (e.g. queries composition)
+- db-abstraction for PostgreSQL and Oracle (e.g. query composition)
 - context-management: context objects for (connections and db-queries)
 - security policies
 - GUI and DOM support (via tdom)
@@ -43,12 +43,13 @@
         <license>BSD-Style</license>
         <maturity>2</maturity>
 
-        <provides url="xotcl-core" version="5.10.0d23"/>
+        <provides url="xotcl-core" version="5.10.0d24"/>
 	<requires url="acs-kernel" version="5.10.0d11"/>
 	<requires url="acs-templating" version="5.9.1"/>
 	<requires url="acs-api-browser" version="5.9.1"/>
 	<requires url="acs-content-repository" version="5.9.1"/>
         <requires url="acs-tcl" version="5.10.0d28"/>
+	<requires url="acs-admin" version="5.10.0d9"/>
 
         <callbacks>
             <callback type="before-install"  proc="::xotcl-core::before-install"/>
Index: openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl,v
diff -u -r1.41.2.10 -r1.41.2.11
--- openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl	29 Nov 2019 15:30:15 -0000	1.41.2.10
+++ openacs-4/packages/xotcl-core/tcl/06-package-procs.tcl	14 Feb 2020 13:42:12 -0000	1.41.2.11
@@ -10,11 +10,14 @@
   #
   # Meta-Class for Application Package Classes
   #
-
   Class create ::xo::PackageMgr \
       -superclass ::xo::db::Class \
       -parameter {
         package_key
+        {default_package_parameters ""}
+        {default_package_parameter_page_info ""}
+        {site_wide_package_parameters ""}
+        {site_wide_package_parameter_page_info ""}
       }
 
   PackageMgr ad_instproc first_instance {-privilege -party_id} {
@@ -60,6 +63,196 @@
     return [lsort -integer $result]
   }
 
+  PackageMgr instproc import_prototype_page {
+    -package_key:required
+    -name:required
+    -parent_id:required
+    -package_id:required
+    {-lang en}
+    {-add_revision:boolean true}
+  } {
+    set page ""
+    set fn [acs_root_dir]/packages/$package_key/www/prototypes/$name.page
+    #:log "--W check $fn"
+    if {[file readable $fn]} {
+      #
+      # We have the file of the prototype page. We try to create
+      # either a new item or a revision from definition in the file
+      # system.
+      #
+      if {[regexp {^(..):(.*)$} $name _ lang local_name]} {
+        set fullName $name
+      } else {
+        set fullName en:$name
+      }
+      :log "--sourcing page definition $fn, using name '$fullName'"
+      set page [source $fn]
+      $page configure \
+          -name $fullName \
+          -parent_id $parent_id \
+          -package_id $package_id
+      #
+      # xowiki::File has a different interface for build-name to
+      # derive the "name" from a file-name. This is not important for
+      # prototype pages, so we skip it
+      #
+      if {![$page istype ::xowiki::File]} {
+        set nls_language [:get_nls_language_from_lang $lang]
+        $page name [$page build_name -nls_language $nls_language]
+        #:log "--altering name of page $page to '[$page name]'"
+        set fullName [$page name]
+      }
+      if {![$page exists title]} {
+        $page set title $object
+      }
+      $page destroy_on_cleanup
+      $page set_content [string trim [$page text] " \n"]
+      $page initialize_loaded_object
+
+      set p [::$package_id get_page_from_name -name $fullName -parent_id $parent_id]
+      #:log "--get_page_from_name --> '$p'"
+      if {$p eq ""} {
+        #
+        # We have to create the page new. The page is completed with
+        # missing vars on save_new.
+        #
+        #:log "--save_new of $page class [$page info class]"
+        $page save_new
+      } else {
+        #:log "--save revision $add_revision"
+        if {$add_revision} {
+          #
+          # An old page exists already, create a revision.  Update the
+          # existing page with all scalar variables from the prototype
+          # page (which is just partial)
+          #
+          foreach v [$page info vars] {
+            if {[$page array exists $v]} continue ;# don't copy arrays
+            $p set $v [$page set $v]
+          }
+          #:log "--save of $p class [$p info class]"
+          $p save
+        }
+        set page $p
+      }
+      if {$page ne ""} {
+        # we want to be able to address the page via the canonical name ::$item_id
+        set page [::xo::db::CrClass get_instance_from_db -item_id [$page item_id]]
+      }
+    }
+    return $page
+  }
+
+  PackageMgr instproc require_site_wide_info {} {
+    if {![info exists :site_wide_info]} {
+      if {${:site_wide_package_parameter_page_info} ne ""} {
+        set cmd [list ::xowf::require_parameter_page \
+                     -name [dict get ${:site_wide_package_parameter_page_info} name] \
+                     -title [dict get ${:site_wide_package_parameter_page_info} title] \
+                     -instance_attributes [dict get ${:site_wide_package_parameter_page_info} instance_attributes]]
+      } else {
+        set cmd ""
+      }
+      set site_wide_instance_id [acs_admin::require_site_wide_package \
+                                     -package_key ${:package_key} \
+                                     -parameters ${:site_wide_package_parameters} \
+                                     -configuration_command $cmd ]
+      ::xowiki::Package require $site_wide_instance_id
+      dict set :site_wide_info folder_id [::$site_wide_instance_id folder_id]
+      dict set :site_wide_info instance_id $site_wide_instance_id
+    }
+    return ${:site_wide_info}
+  }
+
+  PackageMgr instproc require_site_wide_info {} {
+    if {![info exists :site_wide_info]} {
+      set cmd [list [self] configure_fresh_instance \
+                   -parameter_page_info ${:site_wide_package_parameter_page_info} \
+                   -parameters ${:site_wide_package_parameters} \
+                  ]
+      set site_wide_instance_id [acs_admin::require_site_wide_package \
+                                     -package_key ${:package_key} \
+                                     -configuration_command $cmd]
+      ::xowiki::Package require $site_wide_instance_id
+      dict set :site_wide_info folder_id [::$site_wide_instance_id folder_id]
+      dict set :site_wide_info instance_id $site_wide_instance_id
+    }
+    return ${:site_wide_info}
+  }
+
+  PackageMgr instproc configure_fresh_instance {
+    {-package_id:required}
+    {-parameter_page_info ""}
+    {-parameters ""}
+  } {
+    if {[llength $parameter_page_info] > 0} {
+      ::xowf::require_parameter_page \
+          -package_id $package_id \
+          -name [dict get $parameter_page_info name] \
+          -title [dict get $parameter_page_info title] \
+          -instance_attributes [dict get $parameter_page_info instance_attributes]
+    }
+    #
+    # Configuring of the parameters is performed after the optional
+    # configuration of the parameter page, since by setting the
+    # package parameter "parameter_page" to a page that does not exist
+    # yet, would lead to errors.
+    #
+    if {[llength $parameters] > 0} {
+      foreach {parameter value} $parameters {
+        ::parameter::set_value \
+            -package_id $package_id \
+            -parameter $parameter \
+            -value $value
+      }
+    }
+  }
+
+  PackageMgr instproc require_site_wide_pages {
+    {-refetch:boolean false}
+  } {
+    set info [:require_site_wide_info]
+    foreach n {folder.form link.form page.form import-archive.form photo.form} {
+      set item_id [::xo::db::CrClass lookup -name en:$n -parent_id [dict get $info folder_id]]
+      #:log "lookup en:$n => $item_id"
+      if {!$item_id || $refetch} {
+        set page [:import_prototype_page \
+                      -name $n \
+                      -package_key ${:package_key} \
+                      -parent_id [dict get $info folder_id] \
+                      -package_id [dict get $info instance_id] ]
+        :log "Page en:$n loaded as '$page'"
+      }
+    }
+  }
+
+  PackageMgr instproc lookup_side_wide_page {-name:required} {
+    set id [::xo::db::CrClass lookup \
+                -name $name \
+                -parent_id [dict get [:require_site_wide_info] folder_id]]
+    :log "lookup_side_wide_page <$name> uses [:require_site_wide_info] => $id"
+    return $id
+  }
+
+  PackageMgr instproc get_site_wide_page {-name:required} {
+    set item_id [:lookup_side_wide_page -name $name]
+    # :ds "lookup from base objects $name => $item_id"
+    if {$item_id} {
+      set page [::xo::db::CrClass get_instance_from_db -item_id $item_id]
+      set package_id [$page package_id]
+      if {$package_id ne ""} {
+        #$form set_resolve_context -package_id $package_id -parent_id $parent_id
+        ::xo::Package require $package_id
+      }
+
+      return $page
+    }
+    return ""
+  }
+
+
+
+
   PackageMgr ad_instproc initialize {
     -ad_doc
     {-parameter ""}
Index: openacs-4/packages/xowf/xowf.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/xowf.info,v
diff -u -r1.12.2.8 -r1.12.2.9
--- openacs-4/packages/xowf/xowf.info	3 Feb 2020 23:00:23 -0000	1.12.2.8
+++ openacs-4/packages/xowf/xowf.info	14 Feb 2020 13:42:12 -0000	1.12.2.9
@@ -10,15 +10,15 @@
     <inherit-templates-p>t</inherit-templates-p>
     <auto-mount>xowf</auto-mount>
     
-    <version name="5.10.0d13" url="http://openacs.org/repository/download/apm/xowf-5.10.0d13.apm">
+    <version name="5.10.0d14" url="http://openacs.org/repository/download/apm/xowf-5.10.0d14.apm">
         <owner url="mailto:neumann@wu-wien.ac.at">Gustaf Neumann</owner>
         <summary>XoWiki Content Flow - an XoWiki based workflow system implementing state-based behavior of wiki pages and forms</summary>
         <release-date>2017-08-06</release-date>
         <vendor url="http://wu.ac.at">WU Vienna</vendor>
         <maturity>2</maturity>
 
-        <provides url="xowf" version="5.10.0d13"/>
-        <requires url="xowiki" version="5.10.0d48"/>
+        <provides url="xowf" version="5.10.0d14"/>
+        <requires url="xowiki" version="5.10.0d49"/>
 	<requires url="acs-automated-testing" version="5.10.0d9"/>
 
         <callbacks>
Index: openacs-4/packages/xowf/tcl/xowf-callback-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-callback-procs.tcl,v
diff -u -r1.1.2.1 -r1.1.2.2
--- openacs-4/packages/xowf/tcl/xowf-callback-procs.tcl	8 May 2019 14:38:41 -0000	1.1.2.1
+++ openacs-4/packages/xowf/tcl/xowf-callback-procs.tcl	14 Feb 2020 13:42:12 -0000	1.1.2.2
@@ -12,41 +12,15 @@
     Callback when this an xowf instance is created
   } {
     ns_log notice "++++ BEGIN ::xowf::after-instantiate -package_id $package_id"
-    # General setup
-    ::xo::Package initialize -package_id $package_id
-    set folder_id [::$package_id folder_id]
-    
+
     #
     # Create a parameter page for convenience
     #
-    set pform_id [::xowiki::Weblog instantiate_forms -forms en:Parameter.form \
-                      -package_id $package_id]
+    ::xowf::Package configure_fresh_instance \
+        -package_id $package_id \
+        -parameters [::xowf::Package default_package_parameters] \
+        -parameter_page_info [::xowf::Package default_package_parameter_page_info]
 
-    ::xo::db::sql::content_item set_live_revision \
-        -revision_id [::$pform_id revision_id] \
-        -publish_status production
-
-    set ia {
-      MenuBar t top_includelet none production_mode t with_user_tracking t with_general_comments f
-      with_digg f with_tags f
-      ExtraMenuEntries {{entry -name New.Extra.Workflow -label "#xowf.menu-New-Extra-Workflow#" -form /en:Workflow.form}}
-      with_delicious f with_notifications f security_policy ::xowiki::policy1
-    }
-    
-    set parameter_page_name en:xowf-default-parameter
-    set p [::$pform_id create_form_page_instance \
-               -name $parameter_page_name \
-               -nls_language en_US \
-               -default_variables [list title "XoWf Default Parameter" parent_id $folder_id \
-                                       package_id $package_id instance_attributes $ia]]
-    $p save_new
-
-    #
-    # Make the parameter page the default
-    #
-    parameter::set_value -package_id $package_id -parameter parameter_page -value $parameter_page_name
-    callback subsite::parameter_changed -package_id $package_id -parameter parameter_page -value $parameter_page_name
-
     ns_log notice "++++ END ::xowf::after-instantiate -package_id $package_id"
   }
 }
Index: openacs-4/packages/xowf/tcl/xowf-init.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-init.tcl,v
diff -u -r1.3.2.2 -r1.3.2.3
--- openacs-4/packages/xowf/tcl/xowf-init.tcl	9 Sep 2019 17:05:09 -0000	1.3.2.2
+++ openacs-4/packages/xowf/tcl/xowf-init.tcl	14 Feb 2020 13:42:12 -0000	1.3.2.3
@@ -1,5 +1,6 @@
-if {[info commands ::ns_cache_eval] eq ""} {proc ::ns_cache_eval {args} {::ns_cache eval {*}$args}}
-# register the dav interface for the todos
+#
+# Register the dav interface for the todo handler.
+#
 ::xowf::dav-todo register
 
 #
Index: openacs-4/packages/xowf/tcl/xowf-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowf/tcl/xowf-procs.tcl,v
diff -u -r1.28.2.24 -r1.28.2.25
--- openacs-4/packages/xowf/tcl/xowf-procs.tcl	7 Feb 2020 08:44:05 -0000	1.28.2.24
+++ openacs-4/packages/xowf/tcl/xowf-procs.tcl	14 Feb 2020 13:42:12 -0000	1.28.2.25
@@ -27,8 +27,40 @@
       -package_key "xowf" -pretty_name "XoWiki Workflow" \
       -superclass ::xowiki::Package
 
+  Package site_wide_package_parameter_page_info {
+    name en:xowf-site-wide-parameter
+    title "Xowf Site-wide Parameter"
+    instance_attributes {
+      index_page table-of-contents
+      MenuBar t
+      top_includelet none
+      production_mode t
+      with_user_tracking t with_general_comments f with_digg f with_tags f
+      with_delicious f with_notifications f
+      security_policy ::xowiki::policy1
+    }}
+
+  Package site_wide_package_parameters {
+    parameter_page en:xowf-site-wide-parameter
+  }
+
+  Package default_package_parameters {
+    parameter_page en:xowf-default-parameter
+  }
+
+  Package default_package_parameter_page_info {
+    name en:xowf-default-parameter
+    title "Xowf Default Parameter"
+    instance_attributes {
+      MenuBar t top_includelet none production_mode t with_user_tracking t with_general_comments f
+      with_digg f with_tags f
+      ExtraMenuEntries {{entry -name New.Extra.Workflow -form /en:Workflow.form}}
+      with_delicious f with_notifications f security_policy ::xowiki::policy1
+    }
+  }
+
   Package ad_instproc initialize {} {
-    mixin ::xowf::WorkflowPage to every FormPage
+    Add mixin ::xowf::WorkflowPage to every FormPage.
   } {
     #
     # This method is called, whenever an xowf package is initialized.
Fisheye: Tag 1.3.2.1 refers to a dead (removed) revision in file `openacs-4/packages/xowf/www/prototypes/Parameter.form.page'.
Fisheye: No comparison available.  Pass `N' to diff?
Index: openacs-4/packages/xowiki/xowiki.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/xowiki.info,v
diff -u -r1.180.2.31 -r1.180.2.32
--- openacs-4/packages/xowiki/xowiki.info	3 Feb 2020 22:49:12 -0000	1.180.2.31
+++ openacs-4/packages/xowiki/xowiki.info	14 Feb 2020 13:42:12 -0000	1.180.2.32
@@ -10,7 +10,7 @@
     <inherit-templates-p>t</inherit-templates-p>
     <auto-mount>xowiki</auto-mount>
 
-    <version name="5.10.0d48" url="http://openacs.org/repository/download/apm/xowiki-5.10.0d48.apm">
+    <version name="5.10.0d49" url="http://openacs.org/repository/download/apm/xowiki-5.10.0d49.apm">
         <owner url="mailto:neumann@wu-wien.ac.at">Gustaf Neumann</owner>
         <summary>A xotcl-based enterprise wiki system with multiple object types</summary>
         <release-date>2017-08-06</release-date>
@@ -55,8 +55,8 @@
         <license>BSD-Style</license>
         <maturity>2</maturity>
 
-        <provides url="xowiki" version="5.10.0d48"/>
-        <requires url="xotcl-core" version="5.10.0d23"/>
+        <provides url="xowiki" version="5.10.0d49"/>
+        <requires url="xotcl-core" version="5.10.0d24"/>
 	<requires url="acs-datetime" version="5.9.1"/>
         <requires url="acs-kernel" version="5.9.1"/>
 	<requires url="acs-tcl" version="5.10.0d27"/>
Index: openacs-4/packages/xowiki/tcl/package-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/package-procs.tcl,v
diff -u -r1.332.2.44 -r1.332.2.45
--- openacs-4/packages/xowiki/tcl/package-procs.tcl	25 Jan 2020 13:40:39 -0000	1.332.2.44
+++ openacs-4/packages/xowiki/tcl/package-procs.tcl	14 Feb 2020 13:42:12 -0000	1.332.2.45
@@ -16,10 +16,15 @@
         {folder_id 0}
         {force_refresh_login false}
       }
-  # {folder_id "[::xo::cc query_parameter folder_id 0]"}
 
-  if {[apm_version_names_compare [ad_acs_version] 5.2] <= -1} {
-    error "We require at least OpenACS Version 5.2; current version is [ad_acs_version]"
+  Package site_wide_package_parameters {
+    MenuBar 1
+    index_page table-of-contents
+    top_includelet ""
+    with_general_comments 0
+    with_notifications 0
+    with_tags 0
+    with_user_tracking 0
   }
 
   Package ad_proc get_package_id_from_page_id {
@@ -1973,17 +1978,29 @@
     }
 
     if {!$(item_id) && $use_prototype_pages} {
-      array set "" [:item_ref \
-                        -normalize_name false \
-                        -default_lang $default_lang \
-                        -parent_id $parent_id \
-                        $link]
-      set page [::xowiki::Package import_prototype_page \
-                    -package_key [:package_key] \
-                    -name $(stripped_name) \
-                    -parent_id $(parent_id) \
-                    -package_id ${:id} ]
-      #:msg "import_prototype_page for '$(stripped_name)' => '$page'"
+      set item_info [:item_ref \
+                         -normalize_name false \
+                         -default_lang $default_lang \
+                         -parent_id $parent_id \
+                         $link]
+      foreach pkgClass [${:id} info precedence] {
+        if {[$pkgClass exists package_key]} {
+          set package_key [$pkgClass package_key]
+          if {$package_key ne "apm_package"} {
+            set page [::xowiki::Package import_prototype_page \
+                          -package_key $package_key \
+                          -name [dict get $item_info stripped_name] \
+                          -parent_id [dict get $item_info parent_id] \
+                          -package_id ${:id} ]
+            if {$page ne ""} {
+              :log "loading prototype page for [dict get $item_info stripped_name] from $package_key"
+              break
+            }
+          }
+        }
+      }
+      #:msg "import_prototype_page for '[dict get $item_info stripped_name]' => '$page'"
+
       if {$page ne ""} {
         # we want to be able to address the page via ::$item_id
         set page [::xo::db::CrClass get_instance_from_db -item_id [$page item_id]]
@@ -2033,138 +2050,49 @@
     }
   }
 
-  Package proc import_prototype_page {
-                                      -package_key:required
-                                      -name:required
-                                      -parent_id:required
-                                      -package_id:required
-                                      {-lang en}
-                                      {-add_revision:boolean true}
-                                    } {
-    set page ""
-    set fn [acs_root_dir]/packages/$package_key/www/prototypes/$name.page
-    #:log "--W check $fn"
-    if {[file readable $fn]} {
-      #
-      # We have the file of the prototype page. We try to create
-      # either a new item or a revision from definition in the file
-      # system.
-      #
-      if {[regexp {^(..):(.*)$} $name _ lang local_name]} {
-        set fullName $name
-      } else {
-        set fullName en:$name
-      }
-      :log "--sourcing page definition $fn, using name '$fullName'"
-      set page [source $fn]
-      $page configure \
-          -name $fullName \
-          -parent_id $parent_id \
-          -package_id $package_id
-      #
-      # xowiki::File has a different interface for build-name to
-      # derive the "name" from a file-name. This is not important for
-      # prototype pages, so we skip it
-      #
-      if {![$page istype ::xowiki::File]} {
-        set nls_language [:get_nls_language_from_lang $lang]
-        $page name [$page build_name -nls_language $nls_language]
-        #:log "--altering name of page $page to '[$page name]'"
-        set fullName [$page name]
-      }
-      if {![$page exists title]} {
-        $page set title $object
-      }
-      $page destroy_on_cleanup
-      $page set_content [string trim [$page text] " \n"]
-      $page initialize_loaded_object
-
-      set p [::$package_id get_page_from_name -name $fullName -parent_id $parent_id]
-      #:log "--get_page_from_name --> '$p'"
-      if {$p eq ""} {
+  Package proc reparent_site_wide_pages {} {
+    #
+    # Reparent the site_wide pages from parent_id -100 to the
+    # site_wide xowiki instance. Reparenting is necessary to keep the
+    # relations to form instances.
+    #
+    # This is transitional code (just for the move). It is safe to
+    # execute this method multiple times.
+    #
+    set site_info [:require_site_wide_info]
+    set parent_id [dict get $site_info folder_id]
+    set page_info [::xo::dc list_of_lists get_site_wide_pages {
+      select item_id,name from cr_items
+      where parent_id = -100
+      and content_type like '::%'
+      and name not like 'xowiki: %';
+    }]
+    xo::dc transaction {
+      foreach {item_id name} [concat {*}$page_info] {
         #
-        # We have to create the page new. The page is completed with
-        # missing vars on save_new.
+        # Avoid potential name clashes in case require_site_wide_pages
+        # was already run and has populated the site.
         #
-        #:log "--save_new of $page class [$page info class]"
-        $page save_new
-      } else {
-        #:log "--save revision $add_revision"
-        if {$add_revision} {
-          #
-          # An old page exists already, create a revision.  Update the
-          # existing page with all scalar variables from the prototype
-          # page (which is just partial)
-          #
-          foreach v [$page info vars] {
-            if {[$page array exists $v]} continue ;# don't copy arrays
-            $p set $v [$page set $v]
-          }
-          #:log "--save of $p class [$p info class]"
-          $p save
+        xo::dc dml maybe_delete_page {
+          delete from cr_items where parent_id = :parent_id and name = :name
         }
-        set page $p
+        #
+        # Reparent page (identified by item_id) to site_wide instance
+        #
+        xo::dc dml reparent_page {
+          update cr_items set parent_id = :parent_id where item_id = :item_id
+        }
       }
-      if {$page ne ""} {
-        # we want to be able to address the page via the canonical name ::$item_id
-        set page [::xo::db::CrClass get_instance_from_db -item_id [$page item_id]]
-      }
     }
-    return $page
   }
 
-  Package proc require_site_wide_pages {
-    {-refetch:boolean false}
-  } {
-    set parent_id -100
-    set package_id [::xowiki::Package first_instance]
-    ::xowiki::Package require $package_id
-    #::xowiki::Package initialize -package_id $package_id -init_url false -keep_cc true
-    set package_key "xowiki"
 
-    foreach n {folder.form link.form page.form import-archive.form photo.form} {
-      set item_id [::xo::db::CrClass lookup -name en:$n -parent_id $parent_id]
-      #:log "lookup en:$n => $item_id"
-      if {!$item_id || $refetch} {
-        set page [::xowiki::Package import_prototype_page \
-                      -name $n \
-                      -package_key $package_key \
-                      -parent_id $parent_id \
-                      -package_id $package_id ]
-        :log "Page en:$n loaded as '$page'"
-      }
-    }
-  }
-
   Package proc preferredCSSToolkit {} {
     return [parameter::get_global_value -package_key xowiki \
                 -parameter PreferredCSSToolkit \
                 -default bootstrap]
   }
 
-  Package proc lookup_side_wide_page {-name:required} {
-    return [::xo::db::CrClass lookup \
-                -name $name \
-                -parent_id -100 \
-                -content_type "::%"]
-  }
-
-  Package proc get_site_wide_page {-name:required} {
-    set item_id [:lookup_side_wide_page -name $name]
-    # :ds "lookup from base objects $name => $item_id"
-    if {$item_id} {
-      set page [::xo::db::CrClass get_instance_from_db -item_id $item_id]
-      set package_id [$page package_id]
-      if {$package_id ne ""} {
-        #$form set_resolve_context -package_id $package_id -parent_id $parent_id
-        ::xo::Package require $package_id
-      }
-
-      return $page
-    }
-    return ""
-  }
-
   Package instproc call {object method options} {
     set allowed [${:policy} enforce_permissions \
                      -package_id ${:id} -user_id [::xo::cc user_id] \
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/xowiki/tcl/parameter-page-procs.tcl'.
Fisheye: No comparison available.  Pass `N' to diff?
Index: openacs-4/packages/xowiki/tcl/upgrade/upgrade.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/upgrade/upgrade.tcl,v
diff -u -r1.15.2.8 -r1.15.2.9
--- openacs-4/packages/xowiki/tcl/upgrade/upgrade.tcl	5 Oct 2019 13:24:53 -0000	1.15.2.8
+++ openacs-4/packages/xowiki/tcl/upgrade/upgrade.tcl	14 Feb 2020 13:42:12 -0000	1.15.2.9
@@ -834,6 +834,13 @@
       ::xowiki::Package require_site_wide_pages -refetch true
     }
 
+    set v 5.10.0d49
+    if {[apm_version_names_compare $from_version_name $v] == -1 &&
+        [apm_version_names_compare $to_version_name $v] > -1} {
+      ns_log notice "-- upgrading to $v"
+      ::xowiki::Package reparent_site_wide_pages
+    }
+
   }
     
 }
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/xowiki/www/prototypes/Parameter.form.page'.
Fisheye: No comparison available.  Pass `N' to diff?
Fisheye: Tag 1.1 refers to a dead (removed) revision in file `openacs-4/packages/xowiki/www/prototypes/table-of-contents.page'.
Fisheye: No comparison available.  Pass `N' to diff?