Item11253: Can RestPlugin users rely on Foswiki::Meta's _indices data member?

pencil
Priority: Enhancement
Current State: No Action Required
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: RestPlugin
Branches:
Reported By: LarsEik
Waiting For:
Last Change By: LarsEik
This is really good functionality, this plugin gives. Is it possible getting a formfield value with javascript? PATCH works for setting a formfield.

I know it's probably coming, but thought creating a task would be at least a little helpful, for testing etc.

Tips from Harvey in the mean time is either parse the topic text with javascript, since that's what RestPlugin GET gives atm, or use a STARTSECTION which takes web, topic and formfield as parameters from and URL with the section parameter.

-- LarsEik - 14 Nov 2011

Actually, I meant something like:
foswiki.RestPlugin.get(
    'System/FAQDownloadSources',
    {
        element: 'topic',
        encoding: 'json',
        success_callback: function (response) {
              var TopicSummary = response.FIELD[response._indices.FIELD['TopicSummary']].value;
            alert(TopicSummary);
        }
    }
);

-- PaulHarvey - 15 Nov 2011

Very humbly I edited topic to be replace with response when parsing the json returned from the server in your example. I had not expected that, me actually getting that to work I mean. Thanks, thanks. This is super cool. I don't get it all but _indices holds the index so it's kinda wrapped in to get the right array element? whatever works smile

This can be closed by my part if not some documentation or something could be updated.

-- LarsEik - 15 Nov 2011

You are correct, of course, that's the problem when I write code from my head without testing it smile

It definitely needs documenting, but then doing so would make us rely on _indices hanging around in the next version of Foswiki.

Sven? Crawford? Any thoughts?

-- PaulHarvey - 15 Nov 2011

yes, i don't want to rely on _indices - its part of the internal mess i'm trying to get rid of (if i have time and motivation) for foswiki2.

-- SvenDowideit - 16 Nov 2011

No, you absolutely can not rely on _indices outside of the class. The clue is in the name - a leading underscore is a perl meta-standard for indicating a private member of a class.

If this functionality is required for a plugin, it must be explicitly exposed (and appropriate thorough unit tests written)

-- CrawfordCurrie - 26 Nov 2011

I see. Will Foswiki's topic serialisation always lack a way to efficiently lookup an datum by its name then?

-- PaulHarvey - 26 Nov 2011

I think this is answered good enough here.

-- LarsEik - 18 Mar 2012
 

ItemTemplate edit

Summary Can RestPlugin users rely on Foswiki::Meta's _indices data member?
ReportedBy LarsEik
Codebase trunk
SVN Range
AppliesTo Extension
Component RestPlugin
Priority Enhancement
CurrentState No Action Required
WaitingFor
Checkins
TargetRelease n/a
ReleasedIn n/a
CheckinsOnBranches
trunkCheckins
Release01x01Checkins
Topic revision: r8 - 18 Mar 2012, LarsEik
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy