[Product-Developers] Remove dashes from shortname - override choosename innamechooser.py?

Imran Azad imran.azad at bradfordhospitals.nhs.uk
Thu Jul 28 14:39:44 UTC 2011

Hi Laurence,

Thank you for the response, it's much appreciated.

Kind Regards

Imran Azad
Web Content Manager
Bradford Teaching Hospitals NHS Foundation Trust

Tel: 01274 38 3556

>>> "Laurence Rowe [via Plone]"
<ml-node+6630087-1003230836-347795 at n2.nabble.com> 28/07/2011 15:37

Giacomo Spettoli wrote:
> Il 27/07/2011 20:34, imran.azad ha scritto:
>> Hi,
>> I want to remove the dashes from the shortname of the object. In
>> words
>> I want to remove all dashes in the id of an object. I have noticed
>> is
>> a function in namechooser.py called chooseName which does the
>> name = getUtility(IURLNormalizer).normalize(name)
>> if I set the variable to:
>> name = name
>> It works! And the dashes aren't added. However this approach is
>> the Plone Core :-(
>> I want to avoid doing this, I would rather like to override the
>> chooseName
>> function.
>> How can I do this from my class(custom content type using
>> Thank You
>> --
>> View this message in context:

>> Sent from the Product Developers mailing list archive at
>> _______________________________________________
>> Product-Developers mailing list
>> Product-Developers at lists.plone.org 
>> https://lists.plone.org/mailman/listinfo/plone-product-developers 
> Hi,
>     you can customize the behaviour of name normalization by
> a local utility that implements IURLNormalizer interface.
> Read more here:


The IURLNormalizer utility is designed for normalizing non-ascii and
characters into something sensible (which is dependent on your
e.g. in German ü normalized to ue.) It is looked up on the request
than the context, so you probably want a custom INameFromTitle adapter
instead. See

for an example dexterity behavior.

That example looks slightly complex because it uses __new__ to ensure
INameFromTitle(object, None) returns None in the case that it can't
determine the primary field for an object, yours should probably just
something like:

class CustomTitleAdapter(object):
    def __init__(self, context):
        self.title = context.title.replace(' ', '')


If you reply to this email, your message will be added to the
discussion below:

To unsubscribe from Remove dashes from shortname - override choosename
in namechooser.py?, visit

Your Hospital needs YOU! We need you to register as a Public, Patient or
Staff member and help shape the future of your healthcare. Call 0800 280
2581 to register by phone or you can email 
bradfordhospitals at capitaregistrars.com  and ask to be registered as a
new member.  For more information about our hospitals and Foundation
Trust Membership please visit www.bradfordhospitals.nhs.uk
This message is confidential. It may also contain privileged
information. The contents of this e-mail and any attachments are
intended for the named addressee only. Unless you are the named
addressee or authorised to receive the e-mail of the named addressee you
may not disclose, use or copy the contents of the e-mail. If you are not
the person for whom the message was intended, please notify the sender
immediately at Bradford Teaching Hospitals NHS Foundation Trust and
delete the material from your computer. You must not use the message for
any other purpose, nor disclose its contents to any person other than
the intended recipient. Bradford Teaching Hospitals NHS Foundation Trust
does not accept responsibility for this message and any views or
opinions contained in this e-mail are solely those of the author unless
expressly stated otherwise.

View this message in context: http://plone.293351.n2.nabble.com/Remove-dashes-from-shortname-override-choosename-in-namechooser-py-tp6627262p6630091.html
Sent from the Product Developers mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.plone.org/pipermail/plone-product-developers/attachments/20110728/a504eba4/attachment.html>

More information about the Product-Developers mailing list