The Toolkit for Online Communities
17701 Community Members, 1 member online, 3957 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : xotcl object cache behavior? : One Message

Forum OpenACS Development: Re: Re: xotcl object cache behavior?

Posted by Stan Kaufman on
Ooops, I meant a ::xowiki::Package proc get_root_folder_object_id {package_id} method -- ie one that returns the id of the root folder's associated object.
Posted by Gustaf Neumann on
Stan, there are currently two approaches implemented to determine the folder_id (needed in different situations):
  1. In oder to determine the (root) folder_id from a package (e.g. in order to fetch xowiki pages from this folder)

    set Package [::xowiki::Package create ::$package_id]
    set folder_id [$Package folder_id]

  2. In order to determine the folder_id from a page:

    set folder_id [$page parent_id]
As said before, this describes the situatiton in the current release 0.34, it might change in the future (when e.g. subfolders are introduced, etc). i am currently working to make it easier to get the connection context (setting up package-id, user-id etc for e.g. testing) there will be calls to take care of these issues as well and setup the package objects etc. automatically). if someone reads this posting later, things might have changed.

It took me yesterday a couple of hours to find a bug where i had several code pieces with ::namespace:cmd (note the missing second colon), so i need some break or better glasses. i am currently finishing a ~1000 page book, and i am doing the xowiki stuff mostly as a recreational activity. On the 18th i am going on vacation, until then i try to finish up the pending things.

best regards

Posted by Stan Kaufman on
Gustaf, those steps return the folder_id -- but not the id of the folder's associated object -- which is what is needed to instantiate the object itself, as you explained earlier:

assume, you have a folder 16059, you might have
a folder object with the id 16068 and the name ::16059
The next two commands do create the object and show it to
you (you can run this from the shell).

::xowiki::Package instantiate_page_from_id -item_id 16068
::Serializer deepSerialize ::16068

Is there somewhere in the api that returns the id "16068" in your example? In any case, I see how to work around this for now, and I realize that you're actively working on all this. I really appreciate all your ongoing contributions! You are amazingly productive!

By the way, is your book entitled "Using XOTCL with OpenACS"? That would be a most excellent title! :-)

Posted by Gustaf Neumann on
sorry, i thought the question was to obtain the folder id, i misread your posting. There is not a big need for an api, since once a package is instantiated, the folder_object is as well. you just need the package_id to get all you want. here is, how you get the interesting ids:

set P [::xowiki::Package create ::$package_id]
set folder ::[$P folder_id]
set folder_id [$folder set folder_id]
set folder_item_id [$folder set item_id]
set folder_revision_id [$folder set revision_id]

btw, in the next release, you can do

$folder serialize

instead of the Serializer::...

The new code is stabilizing, and has some cool features. For example, i added some code to instantiate values from an sql query into an object. normally you get the return variables into the current scope of a function. In order to implement this, only one line was needed

::xotcl::Object instforward db_1row -objscope

db_1row is a forwarder applicable to all objects that makes the instance variables of an object to appear as local variables (the flag -objscope). So, if you do a

$obj db_1row query_name "select some_atts from ..."

the return variables are set as instance variables of the object. This is quite important for dynamic sql queries, where there is no control over the output variables, where it is quite easy to overwrite local variables. the standard set of db-commands allows already array output, but for oo style of code, the above variant is much more convenient and saves copying of values...

Posted by Stan Kaufman on
Gustaf, this is *brilliant*! Thanks again!