def get_delegate_pattern(name, trait):
    """ Returns the correct 'delegate' listener pattern for a specified name and
        delegate trait.
    """
    prefix = trait._prefix
    if prefix == '':
        prefix = name
    elif len(prefix) > 1 and prefix[-1] == '*':
        prefix = prefix[:-1] + name
    return ' %s:%s' % (trait._delegate, prefix)
