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
>>> class Buddy:
...     interface.implements(IBuddy)
>>> class BuddyFolder:
...     interface.implements(IBuddyFolder)
>>> 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:

>>> class Container:
...     interface.implements(IContainer)
>>> class Contained:
...     interface.implements(IContained)
>>> 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)
>>> class Contact:
...     interface.implements(IContact)
>>> class Contacts:
...     interface.implements(IContacts)
>>> 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

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.

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

zope.container-3.12.0.zip (149.7 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-3.12.0-py2.7-win-amd64.egg (125.6 kB view details)

Uploaded Egg

zope.container-3.12.0-py2.7-win32.egg (124.9 kB view details)

Uploaded Egg

zope.container-3.12.0-py2.6-win-amd64.egg (125.8 kB view details)

Uploaded Egg

zope.container-3.12.0-py2.6-win32.egg (125.1 kB view details)

Uploaded Egg

zope.container-3.12.0-py2.5-win32.egg (125.0 kB view details)

Uploaded Egg

zope.container-3.12.0-py2.4-win32.egg (126.0 kB view details)

Uploaded Egg

File details

Details for the file zope.container-3.12.0.zip.

File metadata

  • Download URL: zope.container-3.12.0.zip
  • Upload date:
  • Size: 149.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zope.container-3.12.0.zip
Algorithm Hash digest
SHA256 a57059d9ed99e2647a1a837684e0fb720e9ea0df5db2440fe8bf017e86777d00
MD5 dbec9837d071892c97a09ccdc6db578d
BLAKE2b-256 73a9b83ba1c58365feea9e61fbd86c0416781e115e07e2516f08b904363ba5f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.7-win-amd64.egg
Algorithm Hash digest
SHA256 063cae05cf2f5ec051f2f10d32e682046103b145475104b940968104201b8695
MD5 830f153004c500991a8c3234ab7c20fc
BLAKE2b-256 893e244c81e75339abb30c3be06586f764d93296f314ae7d7621b7824799c4f9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.7-win32.egg
Algorithm Hash digest
SHA256 69ca8bd314f4025a09a26de440aaf10900f10cf9d7bafff3069c415bbbab735d
MD5 a4143c107ef271b5bf7dd770b0ba7436
BLAKE2b-256 0e2985dbc8f2dafc85e6d057f35dfba8c7c124a8acf358b5e080c516e7aecb81

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.6-win-amd64.egg
Algorithm Hash digest
SHA256 989adc9c9865775c68110c93286702cbe88ba21ad68994fe4ecc438cb1047e8b
MD5 62b5cd2d52153cf5d47980ba168fc8da
BLAKE2b-256 a7b4853a89e13da875614ee6a6008fc548ca15fdb2db6436b6d4e781edb22351

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.6-win32.egg
Algorithm Hash digest
SHA256 ff389e39da42a6c164e03d93bbcd6c9b119d33d97a2d3e0bfed521b9ce5fbabb
MD5 e40ee39f28eddeb55546cdbd79e209da
BLAKE2b-256 523a2db4b5151bc62685817369f2ee89ed5dd4764a87a6799bb87c003a7a76a1

See more details on using hashes here.

File details

Details for the file zope.container-3.12.0-py2.5-win32.egg.

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.5-win32.egg
Algorithm Hash digest
SHA256 8d59ae31645aae4297d58d2363ec192c8466fd66166b986e42414d72acafaced
MD5 35b2aaa60bc9fbbb45ec5b2217f41679
BLAKE2b-256 e350b5b97ec69347ebcf699503a1144ac7c7b2dcf84640d505913532542237af

See more details on using hashes here.

File details

Details for the file zope.container-3.12.0-py2.4-win32.egg.

File metadata

File hashes

Hashes for zope.container-3.12.0-py2.4-win32.egg
Algorithm Hash digest
SHA256 5538c656e5258049c1a36fb53733457795404738897f1a7784bfeced03238840
MD5 1a5f86a9c8bb2b52e3c79e936b1154f2
BLAKE2b-256 b4785a0b971be4e98a6e9cc4c588d22eab0cbd3921b4d4544a7b88cd220cc0e5

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