[Zope-CMF] Re: [dev] CMFSetup: proposal for improving handlers

Dieter Maurer dieter at handshake.de
Fri Dec 17 14:32:11 EST 2004


yuppie wrote at 2004-12-17 11:07 +0100:
> ..
>>>I started my prototype with explicit dictionary keys like here:
>>>
>>>    { 'permission': {'key': 'permissions', 'default': ()} }
>>>
>>>But I replaced them later with constants imported from one place to 
>>>catch typos easily.
>> 
>> 
>> For an example, it is better to use the string constants literally
>> rather than hiding them behind constants.
>> 
>
>Why? The pattern I chose is used in many places. And it makes sure you 
>get an error if you misspelled a name.
>
>The values behind the constants are meaningless:
>
>     CONVERTER, DEFAULT, KEY = range(3)

Funny. I use this style only at places where I am concerned about
maximal efficiency. At other places, I prefer string literals.

The problem stems from the fact that some concept has been introduced
by an example (with unexplained magic keys "KEY", "DEFAULT", ...).
I would have had less difficulties when the concept were introduced
by a description. Something along the lines:
   
   values are dictionaries with the optional keys
   "KEY", "DEFAULT", "CONVERTER".
   The associated values have the following meaning (I am not
   yet sure what "KEY" or "CONVERTER" mean) ...
   These keys are constants defined in ...

-- 
Dieter


More information about the Zope-CMF mailing list