Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A Zope 3 extension for pluggable display names.

Project Description


Default Display Name Generator

The default display name generator simply takes a Dublin Core title or a __name__ and returns it, truncated if desired. It uses a helper function intended to make writing other display name generators easier, convertName.

No help is offered yet for using HTML with the IBrowserDisplayNameGenerator interface.

Given an ILocation that can be adapted to zope.dublincore.interfaces.IDCDescriptiveProperties, and that actually has a value for it, it returns the DC title; otherwise, it uses __name__.

>>> import zope.dublincore.interfaces
>>> import zope.location.interfaces
>>> from zc.displayname import interfaces, adapters
>>> from zope.interface import verify
>>> from zope import interface
>>> class Dummy(object):
...     interface.implements(zope.location.interfaces.ILocation)
...     def __init__(self, parent, name):
...         self.__parent__ = parent
...         self.__name__ = name
>>> d = Dummy('parent', 'a name')
>>> from zope.publisher.browser import TestRequest
>>> g = adapters.DefaultDisplayNameGenerator(d, TestRequest())
>>> verify.verifyObject(interfaces.IDisplayNameGenerator, g)
>>> g()
'a name'
>>> g('foo')
Traceback (most recent call last):
TypeError: ('maxlength must be int', 'foo')
>>> g(-1)
Traceback (most recent call last):
ValueError: ('maxlength must be 0 or greater', -1)
>>> g(4)
>>> g(6)
'a name'
>>> g(2)
>>> interface.directlyProvides(
...     d, zope.dublincore.interfaces.IDCDescriptiveProperties)
>>> d.title = 'My Special Dummy'
>>> d.description = 'My interface said I had to have this'
>>> verify.verifyObject(
...     zope.dublincore.interfaces.IDCDescriptiveProperties, d)
>>> g()
'My Special Dummy'
>>> g(0)
>>> g(100)
'My Special Dummy'
>>> g(16)
'My Special Dummy'
>>> g(15)
'My Special D...'
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
zc.displayname-1.1.tar.gz (8.4 kB) Copy SHA256 Checksum SHA256 Source Feb 25, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting