Forum OpenACS Development: Re: caching ns_sets

Collapse
8: Re: caching ns_sets (response to 1)
Posted by Ola Hansson on
Jeff,

How about using db_multirow instead of db_list_of_ns_sets in "list_users_not_cached", and then call template::util::multirow_to_list (I found a bug in this one - see below)? "list_users" could return a memoized copy of that list of lists in array settable format.

If we don't want to hack all the scripts that call "list_users" we could transform the cached list into a list of ns_sets to be returned for now, no?

There does not appear to exist any db api that directly returns a list-of-lists-in-array-settable-format, and that's a shame. Or is it just escaping my eyes...?

Bug in template::util::multirow_to_list:

ad_proc -public template::util::multirow_to_list { name } {
    generate a list structure representitive of a multirow data source

    @param name the name of an existing multirow data source

    @return a representation of a multirow data source as a list,
    suitable for passing by value in the form { { row } { row } { row } ... }

    @see proc template::util::list_to_multirow
} {

  upvar $name:rowcount rowcount

  set rows [list]

  for { set i 1 } { $i <= $rowcount } { incr i } {

    #upvar $name:$rownum row
    upvar $name:$i row
    lappend rows [array get row]
  }

  return $rows
}
("upvar $name:$rownum row" should be "upvar $name:$i row")

I think Jeff wrote a page about how to make proper patches some time ago, if I'm not mistaken. It would be great if someone can point me to it so I can begin to submit such patches. Thanks.

Collapse
10: Re: caching ns_sets (response to 8)
Posted by Jeff Davis on
that is exactly the format I think is better :)

The patch instructions are at:
https://openacs.org/bugtracker/openacs/patch-submission-instructions.html
(although I guess I should update it since I left out that
diff -uN does not always work since solaris only has diff -c
style context diffs).