+ let dbh = Cocanwiki._get_dbh r in
+
+ (* Get the template hosts. *)
+ let sth = dbh#prepare_cached "select id, canonical_hostname from hosts
+ where is_template order by 2" in
+ sth#execute [];
+
+ let table = sth#map (function [`Int id; `String canonical_hostname] ->
+ [ "id", Template.VarString (string_of_int id);
+ "canonical_hostname",
+ Template.VarString canonical_hostname ]
+ | _ -> assert false) in
+ template#table "templates" table;
+