Question
I'm trying to write a little script that takes data from Cairo users home pages and puts it into forms like those who registered after we upgraded, but am having problems saving the new Meta data using the TWiki API.
I have read the documentation at
TWikiMetaDotPm but it wasn't too helpful. Here is what I have tried so far:
1)
my @AoH = (
{
name => "FirstName",
title => "FirstName",
value => "Bobby",
},
{
name => "LastName",
title => "LastName",
value => "Charlton",
},
);
$userMeta->putKeyed('FIELD', @AoH);
This just put the first name in.
2)
my %HoH = (
"FirstName" => {
title => "FirstName",
value => "Bobby",
},
"LastName" => {
title => "LastName",
value => "Charlton",
},
);
$userMeta->putKeyed('FIELD', \%HoH);
Thought this to be more likely to work, but it puts in something like
FirstName="HASH(0x8fc6a8c)" LastName="HASH(0x8f4e208)"
(Have also tried the above defining the
name attribute but same result).
Can anyone help on this?
Also, as a side problem, I'm using the following to allow me to get at the API:
BEGIN {
require '../bin/setlib.cfg';
};
use TWiki;
$TWiki::Plugins::SESSION = new TWiki();
However, this starts the session as
TWikiGuest, which means I cannot save topics which have had access permissions on them. Is it possible to define which user I am?
Cheers,
Andrew
Environment
--
AndrewRJones - 15 Dec 2006
Answer
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.
You need to use the first version, but call putKeyed separately for each entry in the array.
If you write your script so it looks like the
view script (i.e. it calls
TWiki::UI::run, passing in the address of the function you want to execute) then you automatically get support for the
user parameter, which lets you define the username on the command line.
--
CrawfordCurrie - 04 Jan 2007
Closing as answered...
--
PeterThoeny - 07 Feb 2007