On Fri, Apr 3, 2009 at 7:21 PM, Wichert Akkerman <wichert@wiggy.net> wrote:
Previously Chris Rossi wrote:This looks like a poor man's enum. I'ld prefer to have a proper enum
> I was wondering if the Zope collective had given any consideration to
> allowing constants to be defined in interfaces. To be clear, these are
> constant values that make up the protocol defined by the interface. Just to
> have a concrete example, let's say we're modeling an http response:
>
> class IHttpResponse(Interface):
> """Models an HTTP 1.1 response.
> """
> status = Attribute("HTTP status code for this response.")
>
> It might be useful to include in our interface spec what some proper values
> for status code might be and make them available to applications as static
> constants on the interface class. A naive implementer might do something
> like this:
>
> class IHttpResponse(Interface):
> """Models an HTTP 1.1 response.
> """
> HTTP_OK = "200 Ok"
> HTTP_NOT_FOUND = "404 Not Found"
>
> status = Attribute("HTTP status code for this response.")
like thing.