Skip to main content

Zope Container

Project description

This package define interfaces of container components, and provides container implementations such as a BTreeContainer and OrderedContainer, as well as the base class used by zope.site.folder for the Folder implementation.

Containment constraints

Containment constraints allow us to express restrictions on the types of items that can be placed in containers or on the types of containers an item can be placed in. We express these constraints in interfaces. Let’s define some container and item interfaces:

>>> from zope.container.interfaces import IContainer
>>> from zope.location.interfaces import IContained
>>> from zope.container.constraints import containers, contains
>>> class IBuddyFolder(IContainer):
...     contains('.IBuddy')

In this example, we used the contains function to declare that objects that provide IBuddyFolder can only contain items that provide IBuddy. Note that we used a string containing a dotted name for the IBuddy interface. This is because IBuddy hasn’t been defined yet. When we define IBuddy, we can use IBuddyFolder directly:

>>> class IBuddy(IContained):
...     containers(IBuddyFolder)

Now, with these interfaces in place, we can define Buddy and BuddyFolder classes and verify that we can put buddies in buddy folders:

>>> from zope import interface
>>> @interface.implementer(IBuddy)
... class Buddy:
...     pass
>>> @interface.implementer(IBuddyFolder)
... class BuddyFolder:
...     pass
>>> from zope.container.constraints import checkObject, checkFactory
>>> from zope.component.factory import Factory
>>> checkObject(BuddyFolder(), 'x', Buddy())
>>> checkFactory(BuddyFolder(), 'x', Factory(Buddy))
True

If we try to use other containers or folders, we’ll get errors:

>>> @interface.implementer(IContainer)
... class Container:
...     pass
>>> @interface.implementer(IContained)
... class Contained:
...     pass
>>> checkObject(Container(), 'x', Buddy())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidContainerType: ...
>>> checkFactory(Container(), 'x', Factory(Buddy))
False
>>> checkObject(BuddyFolder(), 'x', Contained())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidItemType: ...
>>> checkFactory(BuddyFolder(), 'x', Factory(Contained))
False

In the example, we defined the container first and then the items. We could have defined these in the opposite order:

>>> class IContact(IContained):
...     containers('.IContacts')
>>> class IContacts(IContainer):
...     contains(IContact)
>>> @interface.implementer(IContact)
... class Contact:
...     pass
>>> @interface.implementer(IContacts)
... class Contacts:
...     pass
>>> checkObject(Contacts(), 'x', Contact())
>>> checkFactory(Contacts(), 'x', Factory(Contact))
True
>>> checkObject(Contacts(), 'x', Buddy())
... # doctest: +ELLIPSIS
Traceback (most recent call last):
InvalidItemType: ...
>>> checkFactory(Contacts(), 'x', Factory(Buddy))
False

The constraints prevent us from moving a container beneath itself (either into itself or another folder beneath it):

>>> container = Container()
>>> checkObject(container, 'x', container)
Traceback (most recent call last):
TypeError: Cannot add an object to itself or its children.
>>> import zope.location.interfaces
>>> import zope.interface
>>> subcontainer = Container()
>>> zope.interface.directlyProvides(subcontainer,
...     zope.location.interfaces.ILocation)
>>> subcontainer.__parent__ = container
>>> checkObject(subcontainer, 'x', container)
Traceback (most recent call last):
TypeError: Cannot add an object to itself or its children.

CHANGES

4.0.0 (2014-03-19)

  • Added support for Python 3.4.

  • Added support for PyPy.

4.0.0a3 (2013-02-28)

  • Restore Folder pickle forward/backward compatibility with version 3.12.0 after making it inherit from BTreeContainer.

4.0.0a2 (2013-02-21)

  • Allow testing without checkouts of unreleased zope.publisher and ZODB.

  • Added Python 3 Trove classifiers.

4.0.0a1 (2013-02-20)

  • Added support for Python 3.3.

  • Made Folder class inherit from BTreeContainer class, so that the IContainer interface does not need to be re-implemented. Added a data attribute for BBB.

  • Replaced deprecated zope.component.adapts usage with equivalent zope.component.adapter decorator.

  • Replaced deprecated zope.interface.implements usage with equivalent zope.interface.implementer decorator.

  • Dropped support for Python 2.4 and 2.5.

  • Send IContainerModifiedEvent after the container is modified (LP#705600).

  • Preserve the original exception traceback in OrderedContainer.__setitem__.

  • Handle Broken Objects more gracefully

  • Fix a bug that made it impossible to store None values in containers (LP#1070719).

3.12.0 (2010-12-14)

  • Fix detection of moving folders into itself or a subfolder of itself. (#118088)

  • Fixed ZCML-related tests and dependencies.

  • Added zcml extra dependencies.

3.11.1 (2010-04-30)

  • Prefer the standard libraries doctest module to the one from zope.testing.

  • Added compatibility with ZODB3 3.10 by importing the IBroken interface from it directly. Once we can rely on the new ZODB3 version exclusively, we can remove the dependency onto the zope.broken distribution.

  • Never fail if the suggested name is in a wrong type (#227617)

  • checkName first checks the parameter type before the emptiness.

3.11.0 (2009-12-31)

  • Copy two trivial classes from zope.cachedescriptors into this package, which allows us to remove that dependency. We didn’t actually use any caching properties as the dependency suggested.

3.10.1 (2009-12-29)

  • Moved zope.copypastemove related tests into that package.

  • Removed no longer used zcml prefix from the configure file.

  • Stop importing DocTestSuite from zope.testing.doctestunit. Fixes compatibility problems with zope.testing 3.8.4.

3.10.0 (2009-12-15)

  • Break testing dependency on zope.app.testing.

  • Break testing dependency on zope.app.dependable by moving the code and tests into that package.

  • Import ISite from zope.component after it was moved there from zope.location.

3.9.1 (2009-10-18)

  • Rerelease 3.9.0 as it had a broken Windows 2.6 egg.

  • Marked as part of the ZTK.

3.9.0 (2009-08-28)

  • Previous releases should be versioned 3.9.0 as they are not pure bugfix releases and worth a “feature” release, increasing feature version.

    Packages that depend on any changes introduced in version 3.8.2 or 3.8.3 should depend on version 3.9 or greater.

3.8.3 (2009-08-27)

  • Move IXMLRPCPublisher ZCML registrations for containers from zope.app.publisher.xmlrpc to zope.container for now.

3.8.2 (2009-05-17)

  • Rid ourselves of IContained interface. This interface was moved to zope.location.interfaces. A b/w compat import still exists to keep old code running. Depend on zope.location>=3.5.4.

  • Rid ourselves of the implementations of IObjectMovedEvent, IObjectAddedEvent, IObjectRemovedEvent interfaces and ObjectMovedEvent, ObjectAddedEvent and ObjectRemovedEvent classes. B/w compat imports still exist. All of these were moved to zope.lifecycleevent. Depend on zope.lifecycleevent>=3.5.2.

  • Fix a bug in OrderedContainer where trying to set the value for a key that already exists (duplication error) would actually delete the key from the order, leaving a dangling reference.

  • Partially break dependency on zope.traversing by disusing zope.traversing.api.getPath in favor of using ILocationInfo(object).getPath(). The rest of the runtime dependencies on zope.traversing are currently interface dependencies.

  • Break runtime dependency on zope.app.dependable by using a zcml condition on the qsubscriber ZCML directive that registers the CheckDependency handler for IObjectRemovedEvent. If zope.app.dependable is not installed, this subscriber will never be registered. zope.app.dependable is now a testing dependency only.

3.8.1 (2009-04-03)

  • Fixed misspackaged 3.8.0

3.8.0 (2009-04-03)

  • Change configure.zcml to not depend on zope.app.component. Fixes: https://bugs.launchpad.net/bugs/348329

  • Moved the declaration of IOrderedContainer.updateOrder to a new, basic IOrdered interface and let IOrderedContainer inherit it. This allows easier reuse of the declaration.

3.7.2 (2009-03-12)

  • Fix: added missing ComponentLookupError, missing since revision 95429 and missing in last release.

  • Adapt to the move of IDefaultViewName from zope.component.interfaces to zope.publisher.interfaces.

  • Add support for reserved names for containers. To specify reserved names for some container, you need to provide an adapter from the container to the zope.container.interfaces.IReservedNames interface. The default NameChooser is now also aware of reserved names.

3.7.1 (2009-02-05)

  • Raise more “Pythonic” errors from __setitem__, losing the dependency on zope.exceptions:

    o zope.exceptions.DuplicationError -> KeyError

    o zope.exceptions.UserError -> ValueError

  • Moved import of IBroken interface to use new zope.broken package, which has no dependencies beyond zope.interface.

  • Made test part pull in the extra test requirements of this package.

  • Split the z3c.recipe.compattest configuration out into a new file, compat.cfg, to reduce the burden of doing standard unit tests.

  • Stripped out bogus develop eggs from buildout.cfg.

3.7.0 (2009-01-31)

  • Split this package off zope.app.container. This package is intended to have far less dependencies than zope.app.container.

  • This package also contains the container implementation that used to be in zope.app.folder.

Download files

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

Source Distribution

zope.container-4.0.0.tar.gz (61.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

zope.container-4.0.0.win-amd64-py3.4.exe (311.6 kB view details)

Uploaded Source

zope.container-4.0.0.win-amd64-py3.3.exe (311.6 kB view details)

Uploaded Source

zope.container-4.0.0.win-amd64-py2.7.exe (314.3 kB view details)

Uploaded Source

zope.container-4.0.0.win-amd64-py2.6.exe (314.3 kB view details)

Uploaded Source

zope.container-4.0.0.win32-py3.4.exe (280.2 kB view details)

Uploaded Source

zope.container-4.0.0.win32-py3.3.exe (280.2 kB view details)

Uploaded Source

zope.container-4.0.0.win32-py2.7.exe (285.9 kB view details)

Uploaded Source

zope.container-4.0.0.win32-py2.6.exe (285.9 kB view details)

Uploaded Source

zope.container-4.0.0-py3.4-win-amd64.egg (140.7 kB view details)

Uploaded Egg

zope.container-4.0.0-py3.4-win32.egg (140.4 kB view details)

Uploaded Egg

zope.container-4.0.0-py3.3-win-amd64.egg (142.4 kB view details)

Uploaded Egg

zope.container-4.0.0-py3.3-win32.egg (142.1 kB view details)

Uploaded Egg

zope.container-4.0.0-py2.7-win-amd64.egg (138.2 kB view details)

Uploaded Egg

zope.container-4.0.0-py2.7-win32.egg (137.3 kB view details)

Uploaded Egg

zope.container-4.0.0-py2.6-win-amd64.egg (138.4 kB view details)

Uploaded Egg

zope.container-4.0.0-py2.6-win32.egg (137.5 kB view details)

Uploaded Egg

File details

Details for the file zope.container-4.0.0.tar.gz.

File metadata

File hashes

Hashes for zope.container-4.0.0.tar.gz
Algorithm Hash digest
SHA256 5c04e61b52fd04d8b7103476532f557c2278c86281aae30d44f88a5fbe888940
MD5 b24d2303ece65a2d9ce23a5bd074c335
BLAKE2b-256 14febb0c445b82ced804619333fb19016b0031eb4296ac803e5b6348b4a466c9

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win-amd64-py3.4.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win-amd64-py3.4.exe
Algorithm Hash digest
SHA256 22f3227a492a3f0347a541c7db54e849d0a4a003a901bb28b91068f7e6b529e8
MD5 1d6eb915e341ca24cb398930e8190fda
BLAKE2b-256 4826cf94cd5aede93f5df90452347d7a4c77b4f47fd0edc1a90a4fd51f6b96ec

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win-amd64-py3.3.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win-amd64-py3.3.exe
Algorithm Hash digest
SHA256 6d79075bda42a77bf92658eacaeeff305dabe3419bc94bcd6e68e07169e8daea
MD5 4c53e1b9d483bd67aa8928589231ad3d
BLAKE2b-256 603f02bd088b1076d5935e3a445b3321caaf4467dd4ec6edb1890c0ebd01bbef

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win-amd64-py2.7.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win-amd64-py2.7.exe
Algorithm Hash digest
SHA256 5a780e2bc40c7baff4926aa7abb15c6e7b5749a88b063360c1bda1b3d9c960cc
MD5 b7aeb992ff0be781dd2630652903fd17
BLAKE2b-256 30d67515399c67073f9966009e06e9b5ec8bb1dc0029718a28d20b6aae642a80

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win-amd64-py2.6.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win-amd64-py2.6.exe
Algorithm Hash digest
SHA256 169b96097da072eaaccf2213f8df633e98d9c020e8ae3eca655a6cbff3e9498f
MD5 46e583a80f73aba393d2b3256baf41ff
BLAKE2b-256 77d410666ec6229dc3f3be034148b1c0832669e71ee4cbcd37a6ea44ca14e84e

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win32-py3.4.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win32-py3.4.exe
Algorithm Hash digest
SHA256 3e7f7005887f42369960da079947d9c014127c0115d84265a907e104fd08d29f
MD5 0c647626de545f14706d4abb7e91f75d
BLAKE2b-256 e282c9c554bc16e996a71ec334405ae582a7e7b82fc6291531cb07c1cc710f53

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win32-py3.3.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win32-py3.3.exe
Algorithm Hash digest
SHA256 06fae2859581f7bb0262624608f295cf509ef81993334cc038cd7d84b696995a
MD5 2378e2a54afd8f6bd12575d73b4170e5
BLAKE2b-256 a7588f67d00a703aa1f91179f6d1bbe5116b4906269f043aba4dd7be8a6e0a5d

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win32-py2.7.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win32-py2.7.exe
Algorithm Hash digest
SHA256 8446f2e189180274598fe09ce90370b4487ed8a72f573c128d100c206ebffbc4
MD5 514734f2148160494ccc4a5dda417881
BLAKE2b-256 e253e32c22ae391ddefc2ccf3ab02fea0f11633ad77d7e7fa7d16a8dbb58434e

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0.win32-py2.6.exe.

File metadata

File hashes

Hashes for zope.container-4.0.0.win32-py2.6.exe
Algorithm Hash digest
SHA256 d04752f1affe9011cd9b9f784089941fcd5982b770cb6841561bc5f39923349a
MD5 2ebca05f9558b20b1bd873c149c8b6b9
BLAKE2b-256 585357c8eefd32e95297eef36f21ff74957e1b8de99c31e1bbf918744ad42fe2

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py3.4-win-amd64.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py3.4-win-amd64.egg
Algorithm Hash digest
SHA256 0a17baaf1c74c13985a277de4dceb1d428bbe691d7d81fa23377549aa8714506
MD5 7e800133708a73f56217119d36448006
BLAKE2b-256 e0c06b8561ab024a78eaae7d83099a8d852b9841163714c59d8763e6e7178549

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py3.4-win32.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py3.4-win32.egg
Algorithm Hash digest
SHA256 a759cfb3d95e4b8ad7a747192b9f972b38f44a8b80fe805c9f9e0873a4ad484b
MD5 0e649589a4b11cc7cffca81dfd236f1c
BLAKE2b-256 a1d36e6a6a8426ca4d28fe2e121579599979e9e8973897b8ced6208067ac9b9a

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py3.3-win-amd64.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py3.3-win-amd64.egg
Algorithm Hash digest
SHA256 184e464665bbf3f96dc961f67ac57be4709bd61c04f8a7c9eb625d0d8cbd07e7
MD5 76201a6ff06802bf50f433d0cb7de644
BLAKE2b-256 0d5bb2764b2855bb894b237b7643e28506d28a22b4d4611cd51efdcd0ffa049e

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py3.3-win32.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py3.3-win32.egg
Algorithm Hash digest
SHA256 47fbd79ea4e892b436f9ced8a88b05f782290a062d47fffd3e4ee48539a91e97
MD5 9e110dfa420d60e924326f111175554b
BLAKE2b-256 cb092ac2314b849d2a12bcf28febf7c098a6a4a1654f75dc3b890a4ca622b62c

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py2.7-win-amd64.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py2.7-win-amd64.egg
Algorithm Hash digest
SHA256 08d7b59a1b7b9d778abe8a4fe83b3fc720af7cf8ab482311b32f4f08419f9205
MD5 6427fae90e07f7b1d78f719e5f5da403
BLAKE2b-256 ed3b03875cd58ac309f033827685ab577957d9939176572f8d61f634b3ded6dd

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py2.7-win32.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py2.7-win32.egg
Algorithm Hash digest
SHA256 cabc073963730448be960a8c87be9148749e4e962cf378b328c5a6ae8ca72a37
MD5 79c61100c9db4a6c34b2cbc5ca88f573
BLAKE2b-256 752b04760a5cb33f85d07b4025614bee14481743757f2fa3980cbdfbd234f2bb

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py2.6-win-amd64.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py2.6-win-amd64.egg
Algorithm Hash digest
SHA256 112bba176378e08598de104b3aa33bb1addb8762f00027eb0052cb95ab10591b
MD5 a612225e3a6c625942dcd29e5802867e
BLAKE2b-256 23a391d895872e8c6ebe0ace2dfe318fb08d8e2533774e4ad8b29fec6531f45f

See more details on using hashes here.

File details

Details for the file zope.container-4.0.0-py2.6-win32.egg.

File metadata

File hashes

Hashes for zope.container-4.0.0-py2.6-win32.egg
Algorithm Hash digest
SHA256 7bbde81420f8ed511d95e2c7a1d5b433d7ddf15c751837904bc62f6a9e9ba2f0
MD5 232e0212cc91de396e2e733aab1c907a
BLAKE2b-256 38cce1df63093fd6294c93bd345af44c95c0f486abc50e128285930de20cd587

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page