Home
The Toolkit for Online Communities
17299 Community Members, 2 members online, 2249 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Development : Modifying xowiki page content from a script

Forum OpenACS Development: Modifying xowiki page content from a script

Icon of envelope Request notifications

I'm working with xowiki 0.60.3 and xotcl-core 0.56.3 and I want to run a script that updates the content from the xowiki PageInstances searching for a special pattern and replacing this content but... The content for the current revision is successfully updated (instance_attributes field in xowiki_page_instance table) but I keep seeing the same content in the web browser, if I check the live revision from that page I see the content updated but not when accesing the page itself, is there anything else I should do to update this change besides modifying the DB with the script.

Thanks

Collapse
Posted by Byron Linares on
I think your problem is the cache data of the object (xowiki::page, etc)
Try

ns_cache flush xotcl_object_cache ::item_id
ns_cache flush xotcl_object_cache ::page_id

And change the page status to ready

use content_item__set_live_revision(:page_id,"ready")

Probably this will work

Sorry for my English

Collapse
Posted by Gustaf Neumann on
Do i understand correctly that you are updating the revision on a change instead of creating a new revision? You have to be aware of the side effects of this and you have to manage this on your own.

To check, whether my guess is right, browse to http://YOURMACHINE/xotcl/cache?cache=xotcl_object_cache
and flush the cache, and retry.

If this helps, then do in your script
::xo::clusterwide ns_cache flush xotcl_object_cache ::$item_id
(and maybe as well with the revision_id, if you fetch items in your program via revision_ids) after the update.

Collapse
Posted by Alvaro Rodriguez on
It worked!

Gustaf,
I'm not sure if this is the way to go, I'm trying to update the content of every Page Instance, is it better to do a new revision every time?, is there a way to get the attributes from the Page Instance, setting the value the way I want and putting it back, treating the Page Instance as an object.

Thanks in advance,

Collapse
Posted by Byron Linares on
If I’m understanding correctly, what you want to do .
You can do it like this

set page [xowiki::Package instantiate_page_from_id -item_id $item_id]

set instance_attributes "ATTRIBUTE ATTRIBUTE_value ...."}

$page set page_template $tmp_item_id
$page set instance_attributes $instance_attributes
$template save
$template initialize_loaded_object

try it,

how do you solved the first problem ?

Collapse
Posted by Alvaro Rodriguez on
Right, I was getting kind of confused, but of course this would be the right way of doing it, creating a new revision every time.

Thanks,

The first problem was solved with doing the flush like Gustaf said.

Collapse
Posted by Gustaf Neumann on
you had any doubts?

in the "stable branch", the best thing is to load the page instance (or FormPage) object, read/write the "instance_attributes", and call "save" on the object. This cares about everything. The cache-page from my last posting is quite convenient to see, what is stored where in these objects.

I am working on improved support for FormPages, but the best thing is to wait for the new stuff until the release in case you are working on a product.

-gustaf neumann