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

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!