[Twisted-Python] AMPBox as an Argument?

Eric P. Mangold eric at teratorn.org
Sun Aug 5 20:17:11 EDT 2012

Hi Lauren

On Fri, Jul 20, 2012 at 10:11:17AM +0200, Laurens Van Houtven wrote:
> Hi,
> Apparently AMPBoxes aren't Arguments. However, I kind of want an AMPBox (like an AMPList, but only one).
Yes it's a pretty common use-case.

Right now you may use an AMPList with a single element. This is perfectly fine. Perhaps a wrapper class that restricts it to a single value would suffice?

It would be easy to commit to Twisted probably.

just a thought

> Use case: my responses have a "location", but a location is composed of several sub-things: place name, country and postal code. {"location": {"placeName": "Krakow", "countryCode": "PL", postalCode: "30-015"}} would be a lot nicer  than having those keys in the top level namespace :)

I do not necessarily agree. I think namespace prefixing, if well defined, is fine on AMP arguments appearing in the top-level packet. Alternatively the AMPList approach is there.

(JSON in AMP Arguments works pretty well I hear, too).


> cheers
> lvh
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python

More information about the Twisted-Python mailing list