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

Provides a formalism for marking adapter specifications as discriminators.

Project Description

Overview

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):

-or-

def gets_only_bar(bar):

Changelog

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]
Release History

Release History

This version
History Node

0.2

History Node

0.1

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
z3c.discriminator-0.2-py2.4.egg (9.0 kB) Copy SHA256 Checksum SHA256 2.4 Egg Nov 26, 2007
z3c.discriminator-0.2.tar.gz (4.4 kB) Copy SHA256 Checksum SHA256 Source Nov 26, 2007

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