We relaunched the TWiki.org project with an expanded TWiki charter, and we invite you to participate! The TWiki.org Code of Conduct agreement took effect on 27 Oct 2008. We ask existing twiki.org users to opt-in. You need to opt-in to participate in the Blog, Codev, Plugins and TWiki webs. -- PeterThoeny - 27 Oct 2008
Tags:
create new tag
, view all tags

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

TWiki version: TWikiRelease04x00x05
TWiki plugins:  
Server OS:  
Web server:  
Perl version: 5.8.5
Client OS:  
Web Browser:  
Categories: Authentication, Forms, Plugins

-- AndrewRJones - 15 Dec 2006

Answer

ALERT! If you answer a question - or have a question you asked answered by someone - please remember to edit the page and set the status to answered. The status is in a drop-down list 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

 
Change status to:
Topic revision: r5 - 17 Feb 2007 - 05:39:44 - PeterThoeny
 
TWIKI.NET
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback