On Fri, Apr 3, 2009 at 7:21 PM, Wichert Akkerman <span dir="ltr"><<a href="mailto:wichert@wiggy.net">wichert@wiggy.net</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">Previously Chris Rossi wrote:<br>
> I was wondering if the Zope collective had given any consideration to<br>
> allowing constants to be defined in interfaces. To be clear, these are<br>
> constant values that make up the protocol defined by the interface. Just to<br>
> have a concrete example, let's say we're modeling an http response:<br>
><br>
> class IHttpResponse(Interface):<br>
> """Models an HTTP 1.1 response.<br>
> """<br>
> status = Attribute("HTTP status code for this response.")<br>
><br>
> It might be useful to include in our interface spec what some proper values<br>
> for status code might be and make them available to applications as static<br>
> constants on the interface class. A naive implementer might do something<br>
> like this:<br>
><br>
> class IHttpResponse(Interface):<br>
> """Models an HTTP 1.1 response.<br>
> """<br>
> HTTP_OK = "200 Ok"<br>
> HTTP_NOT_FOUND = "404 Not Found"<br>
><br>
> status = Attribute("HTTP status code for this response.")<br>
<br>
</div>This looks like a poor man's enum. I'ld prefer to have a proper enum<br>
like thing.<br>
</blockquote><div> </div></div>I'm sure you can think of a lot of uses of constant values where an enum wouldn't be appropriate. I don't know that I'd even use an enum in this made up example. Some use cases might be covered by an enum, sure, but that's not really the point here.<br>
<br>Thanks,<br>Chris<br><br>