[Zope3-dev] service names

Jeffrey P Shell jeffrey@cuemedia.com
Mon, 3 Feb 2003 13:04:36 -0700


Oooo, Good example!

I found this handy once we started doing this with CMF Permisssion 
names, and even now I'm more prone to use the AccessControl.Permissions 
module to avoid the fear of getting spelling, punctuation, and 
capitalization correct, even for 'View'::

     security.declareObjectProtected(Permissions.view)

On Monday, February 3, 2003, at 12:55  PM, Shane Hathaway wrote:

> Jim Fulton wrote:
>> Steve Alexander wrote:
>>> sean.bowman@acm.org wrote:
>>>
>>>> hello,
>>>>
>>>> In all the code I've seen in Z3, the second argument to getService 
>>>> is a
>>>> string literal.  This smells bad to me -- it seems to violate Once 
>>>> And
>>>> Only Once.  Would it be a good idea to use a constant instead of a 
>>>> string
>>>> literal?  For example::
>>>>
>>>>   getService(context, defaultHubIdsName)
>>>
>>>
>>>
>>> Why not just HubIds ?
>>>
>>>   HubIds = 'HubIds'
>>>   getService(context, HubIds)
>> Why not just 'HubIds'?
>> I really fail to see the benefit of a variable or a marker interface 
>> here.
>
> I've been pondering this for a few days.  I like to use global 
> variables as constants to shield myself from certain typos.  In the 
> example below, 'Id' is sometimes misspelled 'ID':
>
> queryService(context, HubIds) -> hub IDs service
> queryService(context, HubIDs) -> NameError
> queryService(context, 'HubIds') -> hub IDs service
> queryService(context, 'HubIDs') -> None
>
> In the last case, the error might go undetected.  So there is at least 
> one benefit to using a variable.  It's not terribly important, but I 
> thought it was worth mentioning. :-)
>
> Shane
>
>
> _______________________________________________
> Zope3-dev mailing list
> Zope3-dev@zope.org
> http://mail.zope.org/mailman/listinfo/zope3-dev