Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install z3c.discriminator

How to install z3c.discriminator

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install z3c.discriminator
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.2 Available View build log
Windows (64-bit)
0.2 Available View build log
Mac OS X (10.5+)
0.2 Available View build log
Linux (32-bit)
0.2 Available View build log
Linux (64-bit)
0.2 Available View build log
 
Author
License
ZPL
Dependencies
Lastest release
version 0.2 on Jan 5th, 2011

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

System Message: WARNING/2 (<string>, line 45)

Bullet list ends without a blank line; unexpected unindent.

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

System Message: WARNING/2 (<string>, line 60)

Bullet list ends without a blank line; unexpected unindent.

[malthe]

Subscribe to package updates

Last updated Jan 5th, 2011

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.