[Twisted-Python] AMPBox as an Argument?

exarkun at twistedmatrix.com exarkun at twistedmatrix.com
Tue Jul 24 09:29:51 EDT 2012

On 12:48 pm, _ at lvh.cc wrote:
>Sure, I just ended up doing that.
>Would it be worth creating a ticket, or am I seriously the first person 
>to want this?

Some general dict argument types would be great.  The kind represented 
by AMPList included.  Note that once we have this, AMPList can actually 
be implemented in like ListOf(Dict()) instead of being a special case. 
This argues against implementing Dict in terms of AMPList, though. ;)

>On 20 Jul 2012, at 10:35, Glyph wrote:
>>On Jul 20, 2012, at 1:11 AM, Laurens Van Houtven <_ at lvh.cc> wrote:
>>>Apparently AMPBoxes aren't Arguments. However, I kind of want an 
>>>AMPBox (like an AMPList, but only one).
>>>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 :)
>>Seems like an easy enough thing to write.  Given that AMPList doesn't 
>>use a length prefix (it uses null-key box-termination, just like the 
>>rest of the protocol) the representation would be exactly the same. 
>>Just add a trivial wrapper that uses AMPList, unpacks its argument, 
>>and assert that there's only one of them?
>>Twisted-Python mailing list
>>Twisted-Python at twistedmatrix.com
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com

More information about the Twisted-Python mailing list