Previously Chris Rossi wrote:
> 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.")

This looks like a poor man's enum. I'ld prefer to have a proper enum
like thing.

Wichert.

-- 
Wichert Akkerman <wich...@wiggy.net>    It is simple to make things.
http://www.wiggy.net/                   It is hard to make things simple.
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - 
 http://mail.zope.org/mailman/listinfo/zope-announce
 http://mail.zope.org/mailman/listinfo/zope )

Reply via email to