This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

This packages allows you to replace, add or delete zope.component registrations of utilities, adapters and event handlers, and to later on undo the changes you made.


To change something in a registry, instantiate gocept.zcapatch.Patches for that registry (if no registry is given, the current one as returned by zope.component.getSiteManager() is used). It offers the following methods:

patch_utility(new, provided=None, name=u”, registry=None):

Register the given new object as a utility, instead of what is currently registered for this interface (and name).

If no provided interface is given, it is read from the object’s zope.interface.implements declaration.

If you want to delete a utility registration, pass new=None.

patch_adapter(factory, required=None, provided=None, name=u”, registry=None):

Register the given factory as an adapter, instead of what is currently registered for these required and provided interfaces (and name).

Any of the required or provided interfaces not given will be read from the object’s zope.component.adapts and zope.interface.implements declarations.

If you want to delete an adapter registration, pass factory=lambda *args: None.

patch_handler(handler, required, registry=None):

Register the given handler instead of what is currently registered for the required interfaces.

If no required interfaces are given, they are read from the object’s zope.component.adapts declaration.

If you want to delete a handler registration, use remove_handler.

remove_handler(handler, required=None, registry=None):

Delete the specified registration of handler. (Since handlers are set-valued, you cannot delete one without explicitly specifying which one you mean.)

If no required interfaces are given, they are read from the object’s zope.component.adapts declaration.


Undo all changes made via this Patches instance: Unregister all utilities, adapters and handlers added, and restore any previously present registrations that were replaced or removed.

Here’s a typical usage example:

import gocept.zcapatch
import unittest

class TestCase(unittest.TestCase):

    def setUp(self):
        self.zca = gocept.zcapatch.Patches()

    def tearDown(self):

    def test_something(self):


plone.testing provides the ability to create a stack of registries, where each delegates to the previous one (plone.testing.zca.pushGlobalRegistry / popGlobalRegistry) – so you could, for example, push a new registry for each test, manipulate that at will, and throw it away afterwards. While this approach is much more elegant than the one provided by gocept.zcapatch for common use cases, do note the following limitations:

  • plone.testing only ever deals with zope.component.getGlobalSiteManager(), so you can’t stack other registries (e.g. LocalSiteManagers as implemented by
  • plone.testing does not allow you to (temporarily) delete registrations from the registry.


The mercurial repository of the source code as well as the issue tracker are available at <>.


1.0 (2011-12-01)

  • first release.
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
gocept.zcapatch-1.0.tar.gz (5.7 kB) Copy SHA256 Checksum SHA256 Source Dec 1, 2011

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