+ Reply to Thread
Results 1 to 10 of 10

Thread: evaluating str args in a dekiscript extension

  1. #1

    Default evaluating str args in a dekiscript extension

    Hello,

    I'm attempting to create an extension for the Sunlight Foundation API using dekiscript. The first function I added peopleConvertID takes 3 arguments, but when I evaluate them they don't appear to contain anything.

    I'm calling it with and the extension code is available bellow:
    {{ sunlight.peopleConvertID("fakeopenID475","entity_i d","GovTrack_ID") }}

    Which seems to return:
    http://api.sunlightlabs.com/people.c...de=&output=xml

    If I'm reading the extension guide correctly I would expect it to return:
    http://api.sunlightlabs.com/people.c..._ID&output=xml

    Any suggestions as to what I might be doing wrong?

    Thanks,
    Ilan

    Script Contents:
    Code:
    <extension>
    	<title>Sunlight API Extension</title>
    	<lable>Sunlight</lable>
    	<copyright>Copyright (c) 2008 BytesFree.org</copyright>
    	<description>This extension contains functions for retreiving content from the Sunlight Foundation API</description>
    	<namespace>sunlight</namespace>
    	
    	<function>
    
    		<name>peopleConvertID</name>
    		<description>Convert between one ID and another, e.g. given an input VoteSmart ID, return the equivalent GovTrack ID</description>
    		<param name="id" type="str" optional="false">An ID of any type</param>
    		<param name="fromcode" type="str" optional="false">one of the codes above specifiying what type of input ID this is</param>
    		<param name="tocode" type="str" optional="false">type of output id</param>
    		<return>
    
    			<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
    				<head></head>
    				<body>
    					<eval:expr>
    						"http://api.sunlightlabs.com/people.convertId.php?id=" .. args.id ..
    						"&amp;fromcode=" .. args.fromcode .. "&amp;tocode=" .. args.tocode ..
    						"&amp;output=xml"
    					</eval:expr>
    				</body>
    			</html>
    
    		</return>
    	</function>
    </extension>

  2. #2
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    Hmm, looking at it, the code seems correct.

    Can you try the following: replace the occurrences of
    args.fromcode
    with
    (args.fromcode ?? "fromcode")

    And so forth. Let me know what happened.

    Also, you can remove optional="false" as that is the default value for the attribute (although, it shouldn't matter).
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  3. #3

    Default

    Steve,
    Thank you for taking a look. Changing it to (args.fromcode ?? "fromcode") results in the following being returned:

    http://api.sunlightlabs.com/people.c...de=&output=xml

    It seems as if args.fromcode is actually null for some reason.

    -Ilan

    Code:
    <extension>
    	<title>Sunlight API Extension</title>
    	<lable>Sunlight</lable>
    	<copyright>Copyright (c) 2008 BytesFree.org</copyright>
    	<description>This extension contains functions for retreiving content from the Sunlight Foundation API</description>
    	<namespace>sunlight</namespace>
    	
    	<function>
    
    		<name>peopleConvertID</name>
    		<description>Convert between one ID and another, e.g. given an input VoteSmart ID, return the equivalent GovTrack ID</description>
    		<param name="id" type="str">An ID of any type</param>
    		<param name="fromcode" type="str">one of the codes above specifiying what type of input ID this is</param>
    		<param name="tocode" type="str">type of output id</param>
    		<return>
    
    			<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
    				<head></head>
    				<body>
    					<eval:expr>
    						"http://api.sunlightlabs.com/people.convertId.php?id=" .. args.id ..
    						"&amp;fromcode=" .. (args.fromcode ?? "fromcode") .. "&amp;tocode=" .. args.tocode ..
    						"&amp;output=xml"
    					</eval:expr>
    				</body>
    			</html>
    
    		</return>
    	</function>
    </extension>

  4. #4
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    Interesting. So it appears the parameters aren't passed in correctly. Very odd.

    This this:
    Code:
    <extension>
    	<title>Sunlight API Extension</title>
    	<lable>Sunlight</lable>
    	<copyright>Copyright (c) 2008 BytesFree.org</copyright>
    	<description>This extension contains functions for retreiving content from the Sunlight Foundation API</description>
    	<namespace>sunlight</namespace>
    	
    	<function>
    		<name>peopleConvertID</name>
    		<description>Convert between one ID and another, e.g. given an input VoteSmart ID, return the equivalent GovTrack ID</description>
    		<param name="id" type="str">An ID of any type</param>
    		<param name="fromcode" type="str">one of the codes above specifiying what type of input ID this is</param>
    		<param name="tocode" type="str">type of output id</param>
    		<return>
    			<html xmlns:eval="http://mindtouch.com/2007/dekiscript">
    				<head></head>
    				<body>
    					<eval:expr>args</eval:expr>
    				</body>
    			</html>
    		</return>
    	</function>
    </extension>
    Note that if you're using 1.9.0b, the following should do the same:
    Code:
    <extension>
    	<title>Sunlight API Extension</title>
    	<lable>Sunlight</lable>
    	<copyright>Copyright (c) 2008 BytesFree.org</copyright>
    	<description>This extension contains functions for retreiving content from the Sunlight Foundation API</description>
    	<namespace>sunlight</namespace>
    	
    	<function>
    		<name>peopleConvertID</name>
    		<description>Convert between one ID and another, e.g. given an input VoteSmart ID, return the equivalent GovTrack ID</description>
    		<param name="id" type="str">An ID of any type</param>
    		<param name="fromcode" type="str">one of the codes above specifiying what type of input ID this is</param>
    		<param name="tocode" type="str">type of output id</param>
    		<return type="map">args</return>
    	</function>
    </extension>
    Either one should show you the complete 'args' instance that was passed in.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  5. #5

    Default

    Hmm, its outputing as if it received no arguements. I.E:

    {}

  6. #6

    Default

    By the way, I am running 1.9.0b.

  7. #7
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    I can repro the issue locally, but can't tell you yet why it's happening.
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  8. #8
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    Aha! Found the problem. Not surprisingly, it's a bug on our side.

    But, there is an easy work around!

    Code:
    <extension>
    	<title>Sunlight API Extension</title>
    	<lable>Sunlight</lable>
    	<copyright>Copyright (c) 2008 BytesFree.org</copyright>
    	<description>This extension contains functions for retreiving content from the Sunlight Foundation API</description>
    	<namespace>sunlight</namespace>
    	
    	<function>
    		<name>peopleconvertid</name>
    		<description>Convert between one ID and another, e.g. given an input VoteSmart ID, return the equivalent GovTrack ID</description>
    		<param name="id" type="str">An ID of any type</param>
    		<param name="fromcode" type="str">one of the codes above specifiying what type of input ID this is</param>
    		<param name="tocode" type="str">type of output id</param>
    		<return type="map">args</return>
    	</function>
    </extension>
    The name of the function must be in lowercase! We use an xpath internally to locate the function definition and xpath is case-sensitive. This shouldn't be the case. The issue will be fixed in 1.9.1.

    Thanks for pointing it out!!
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

  9. #9

    Default

    Thanks! I'll go ahead and give this a shot.

  10. #10
    Join Date
    Jul 2006
    Location
    San Diego, CA
    Posts
    5,450

    Default

    Filed a tracking issue on this:
    http://bugs.opengarden.org/view.php?id=3689
    Steve G. Bjorg - Chief Architect
    Did you check the MindTouch FAQ?
    Found a bug? Report it.
    Follow me on Twitter
    Find us on IRC: irc.freenode.net #mindtouch

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts