On Dec 26, 2011, at 12:21 PM, Ralph Meijer wrote: > Hi, > > I've been looking into using twisted.python.constants for representing > the status codes of the XMPP Multi-User Chat protocol [1]. I will have > objects representing messages, of which one of the attributes is > 'mucStatuses', a set of status codes. This works out great for the > initial set of available status codes. The protocol is parsed, and the > status codes are represented by the ValueConstant instances returned by > lookupByValue. > > However, not all of the possible codes can be known up-front, as the > protocol allows for registering new ones without changing the > specification itself. Eventually, applications will receive status codes > that are not (yet?) part of the set of defined constants in the > implementation, and application developers (that do know about new > codes) will want to handle these. > > A possible remedy to would be to register new status codes from the > application itself. My first try of just adding a new attribute to the > class fails because they are not 'realized' as the _enumerants are cached. > > I can imagine this also goes for unknown HTTP methods and HTTP status > codes, used as examples in the documentation. Any suggestions on how to > handle such unknown constants? > > > [1] <http://xmpp.org/extensions/xep-0045.html#statuscodes>
twisted.python.constants is a work in progress; there are many planned features that it doesn't have yet. Perhaps you should simply add the feature that you want - the ability to adding new attributes to the class? -glyph _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python