[Zope-dev] Standard namechooser

Christian Theune ct at gocept.com
Mon Feb 11 10:18:11 EST 2008



Aaron Lehmann schrieb:
> 
> On Feb 11, 2008, at 10:06 AM, Christian Theune wrote:
> 
>> Hi,
>>
>> Aaron Lehmann schrieb:
>>> Christian,
>>> What if people are relying on those error messages to do different 
>>> things?
>>> Possibly they already have normalization code they expect to come 
>>> into play in this situation, which is different than yours
>>> .
>>
>> I see that people might be doing that, however, it seems like a bad 
>> idea to code that way. ;)
> 
> Maybe.  But enforcing this on others seems to cut against "consenting 
> adults."  After all, how do you know that your desired resolution is the 
> resolution for everyone?

Sure, that's why I'm discussing it here. ;)

>>> On the other hand, having to do this seems annoying, so as someone 
>>> writing new code I'd consider your proposed patch a feature, rather 
>>> than a bugfix.
>>
>> I'd be happy to declare it a feature, but I consider the existing 
>> state to not be ideal and thus it should be changed.
> 
> Possibly instead of returning an error, it might resolve the name, and 
> take an optional callback that performs said resolution?  That way, 
> people who have their own resolution code can easily factor it in.

Hmm. Sounds like a little too much engineering and not very componentish 
to me.

Up to this point my thinking went this way: We have an interface that 
allows us to a) check whether a name is ok b) create a name that is ok 
for us, probably considering a name that we give him.

The second method feels like it should never raise an error - that's 
what the `check` method is for.

If you want to customize the behaviour, you can always create a 
different name chooser implementation. It doesn't have to be 100% 
correct for everyone, but it should avoid the 80% pitfalls and it 
certainly should implement the interface the way it is intended.

Unfortunately the interface is a bit unspecific whether chooseName may 
raise an error if the given name does not conform to checkName or 
whether it is obligued to always pick a good one.

Christian

-- 
gocept gmbh & co. kg - forsterstrasse 29 - 06112 halle (saale) - germany
www.gocept.com - ct at gocept.com - phone +49 345 122 9889 7 -
fax +49 345 122 9889 1 - zope and plone consulting and development


More information about the Zope-Dev mailing list