[Zope3-dev] Re: Using classes as constants for security settings
Steve Alexander
steve@cat-box.net
Mon, 18 Feb 2002 09:46:20 +0000
Chris Withers wrote:
> Steve Alexander wrote:
>
>> def _setDescription(self, description):
>> self._description=description
>>
>> def getDescription(self):
>> return self._description
>>
>
> What's description used for?
Actually, the more important question is "what's __str__ and __repr__
used for?".
I'd like to be able to do this:
>>> from Settings import Allow
>>> print "My setting is %s" % Allow
My setting is Allow
With integer constants, I'd get:
>>> print "My setting is %s" % Allow
My setting is 23
Or whatever. Which isn't so informative in logs or debug output.
Then again, this might be more sensible:
Allow: 1
Unset: 0
Deny: -1
Assign: 1
Remove: -1
I still prefer something that will give me text, over numbers.
> 'cos aside from that, they could be just integer literals with names defined
> somewhere, which would be much quicker no matter how you slice it.
Comparing integers be identity shouldn't be much quicker than comparing
classes by identity.
--
Steve Alexander