Skip to main content

Provides a formalism for marking adapter specifications as discriminators.

Project description


z3c.discriminator provides a formalism for marking adapter specifications as discriminators in the sense that they will be used only for adapter lookup, not instantiation.

Using z3c.discriminator

To mark one or more interfaces as discriminators in a provideAdapter call, simply wrap your interface with the discriminator method:

>>> from z3c.discriminator import discriminator
>>> provideAdapter(MyAdapter, (IFoo, discriminator(IBar)))

To do the same in a Zope configuration file, prefix your dotted path with a dash like so:

<adapter for=”IFoo -IBar” factory=”some.package.YourFactory” />

Note that any interface in the declaration can be made a discriminator; they need not come in any particular order.

In your factory definition, simply require only the arguments that correspond to non-discriminator specifications, e.g.

class GetsOnlyFoo(object):
def __init__(self, foo):


def gets_only_bar(bar):


Version 0.2 - November 26, 2007

  • Discriminator machinery is now introduced globally by patching the global adapter registry and the GlobalObject configuration field.

    The discriminator method now returns an interface that is in all aspects equal to the discriminated interface except it’s marked as a discriminator.

    Test suite have been expanded by including the entire test suite from zope.component. [malthe]

Version 0.1 - November 23, 2007

  • First public release [malthe]

Project details

Download files

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

Source Distribution

z3c.discriminator-0.2.tar.gz (4.4 kB view hashes)

Uploaded source

Built Distribution

z3c.discriminator-0.2-py2.4.egg (9.0 kB view hashes)

Uploaded 2 4

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page