← Back to team overview

launchpad-dev team mailing list archive

Re: Exposing a dict on the LP API, was: [Bug 352094] Expose ISourcePackage.branches

 

Just for the record:

{{{
2009 Oct 24 01:33:09 <al-maisan>        hello leonardr, are you around
and could you please help me with a LP API change?
2009 Oct 24 01:34:12 <wgrant>   Is this the SP.branches dict?
2009 Oct 24 01:34:36 <wgrant>   I think that will be difficult or
impossible; I don't know of any existing exported dicts that contain
other entries.
2009 Oct 24 01:34:47 <al-maisan>        wgrant: an attempt, yes.
2009 Oct 24 01:34:54 <al-maisan>        http://pastebin.ubuntu.com/300148/
2009 Oct 24 01:35:53 <al-maisan>        this is the error I get during
testing: http://pastebin.ubuntu.com/300150/
2009 Oct 24 01:36:58 <wgrant>   That's what I expected.
2009 Oct 24 01:37:04 <al-maisan>        hrm
2009 Oct 24 01:37:11 <wgrant>   lazr.restful doesn't treat dicts specially.
2009 Oct 24 01:37:47 <wgrant>   Normally when it sees an enum in a field
it will stringify it, and only then hand it off to be JSON-encoded.
2009 Oct 24 01:37:55 <al-maisan>        wgrant: aha
2009 Oct 24 01:38:52 <wgrant>   And I'm not sure if launchpadlib is set
up to handle dict specifications in WADL.
2009 Oct 24 01:38:55 <leonardr> al-maisan: i'm not really around but i
can try to answer your question
2009 Oct 24 01:39:08 <leonardr> unless wgrant already has
2009 Oct 24 01:39:21 <al-maisan>        leonardr: thanks -- please see
http://pastebin.ubuntu.com/300148/
2009 Oct 24 01:39:23 <leonardr> yes, i odn't think you'll have much luck
exporting a dict
2009 Oct 24 01:39:37 <leonardr> you can publish a named operation that
returns a dict
2009 Oct 24 01:39:38 <wgrant>   There are existing named ops that return
dicts.
2009 Oct 24 01:39:42 <wgrant>   Right.
2009 Oct 24 01:39:47 <al-maisan>        OK
2009 Oct 24 01:39:51 <wgrant>   But I guess launchpadlib won't interpret
any entry links inside them.
2009 Oct 24 01:40:04 <leonardr> no, you'll just have a dict of strings
to strings
2009 Oct 24 01:40:23 <al-maisan>        I'll go down the named operation
route then
2009 Oct 24 01:40:27 <wgrant>   So I guess just export a named op that
takes a pocket.
2009 Oct 24 01:40:29 <leonardr> al-maisan: you should be able to write a
serializer
2009 Oct 24 01:40:34 <leonardr> for dicts
2009 Oct 24 01:40:36 <al-maisan>        leonardr: aha
2009 Oct 24 01:40:39 <wgrant>   leonardr: But won't that require client
changes?
2009 Oct 24 01:40:40 <leonardr> look in lazr.restful for other examples
2009 Oct 24 01:40:51 <al-maisan>        OK
2009 Oct 24 01:41:02 <leonardr> i don't think so. i think the client
will see .foo as a dict
2009 Oct 24 01:41:30 <leonardr> there might be problems changing the
dict and sending it back
2009 Oct 24 01:41:38 <wgrant>   I mean, lazr.restful will serialise it
and stop crashing, but the client will still just see strings.
2009 Oct 24 01:42:00 <al-maisan>        leonardr: changing the dict and
sending it back is not an issue here..
2009 Oct 24 01:42:36 <leonardr> wgrant: yes, the client will still see
strings, but it's better than creating a named operation that will have
the same problem
2009 Oct 24 01:43:00 <leonardr> al-maisan: look in
lazr/restful/marshallers.py
2009 Oct 24 01:43:14 <al-maisan>        leonardr: thanks for the pointer
}}}


Robert Collins wrote:
> On Fri, 2009-10-23 at 21:15 +0200, Muharem Hrnjadovic wrote:
>> How does one expose a property that's a dict on the LP API? Are there
>> any examples of this?
> 
> archive.getBuildSummariesForSourceIds ?
> 
> -Rob
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~launchpad-dev
> Post to     : launchpad-dev@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~launchpad-dev
> More help   : https://help.launchpad.net/ListHelp


Best regards

-- 
Muharem Hrnjadovic <muharem@xxxxxxxxxx>
Public key id   : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F  5602 219F 6B60 B2BB FCFC

Attachment: signature.asc
Description: OpenPGP digital signature


References