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 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

Change status to:
Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2007-02-17 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.