[Pypes-developer] Reserved Attributes and Metadata Keywords for Packets
Status: Beta
Brought to you by:
egaumer
From: Matt W. <ma...@ma...> - 2009-09-19 05:58:44
|
I wanted to added packet level metadata, so I created a patch that sets packet metadata to a special attribute called '__meta__'. Now, this can be a problem if someone wants to use '__meta__' as an attribute in their packet. This is also a current problem with metadata because internally attribute values for packets are stored in a dictionary field called 'value'. Metadata for attributes are stored in whatever meta key you specify. So, if someone to set a metadata field called 'value' on any field, it will break the packet api. To resolve these problems, '__meta__' should be a reserved attribute and 'value' should be a reserved metadata keyword. When you attempt to set a reserved attribute or meta key, you should get KeyError. I implemented this functionality in the patch attached to bug 2860459. The patch completely refactors the internal packet api to support this functionality. All unit tests pass, as do the new ones I added. Also note that I refactored the 'value' key into '__value__' to be consistent with my '__meta__' attribute and reduce the chances for a name conflict. What do you think of this "reserved" concept? See http://sourceforge.net/tracker/?func=detail&aid=2860459&group_id=271766&atid=1155513 . Thanks, Matt Weber |