Skip to main content

zope.interface compliant ordered dictionary.

Project description

zodict

Ordered dictionary which implements the corresponding zope.interface.common.mapping interface.:

>>> from zope.interface.common.mapping import IFullMapping
>>> from zodict import zodict
>>> zod = zodict()
>>> IFullMapping.providedBy(zod)
True

Node

This is a zodict which provides a location.:

>>> from zope.location.interface import ILocation
>>> from zodict.node import Node
>>> root = Node('root')
>>> ILocation.providedBy(Node)
True

>>> root['child'] = Node()
>>> root['child'].path
['root', 'child']

>>> child = root['child']
>>> child.__name__
'child'

>>> child.__parent__
<Node object 'root' at ...>

The filtereditems function.:

>>> from zope.interface import Interface
>>> from zope.interface import alsoProvides
>>> class IMarker(Interface): pass
>>> alsoProvides(root['child']['subchild'], IMarker)
>>> IMarker.providedBy(root['child']['subchild'])
True

>>> for item in root['child'].filtereditems(IMarker):
...     print item.path
['root', 'child', 'subchild']

UUID related operations on Node.:

>>> uuid = root['child']['subchild'].uuid
>>> uuid
UUID('...')

>>> root.node(uuid).path
['root', 'child', 'subchild']

>>> root.uuid = uuid
Traceback (most recent call last):
  ...
ValueError: Given uuid was already used for another Node

>>> import uuid
>>> newuuid = uuid.uuid4()

>>> root.uuid = newuuid
>>> root['child'].node(newuuid).path
['root']

>>> root.uuid = object()
Traceback (most recent call last):
  ...
AssertionError: arg <object object at ...> does not match <class 'uuid.UUID'>

Changes

Version 1.3.1

-Add __delitem__ function to Node.

rnix, 2009-04-16

Version 1.3

-Add uuid Attribute and node function to Node.

rnix, 2009-03-23

Version 1.2

-Add filtereditems function to Node.

rnix, 2009-03-22

Version 1.1

-Add INode interface and implementation.

rnix, 2009-03-18

Credits

-Written by Robert Niederreiter <rnix@squarewave.at> (2009-03-17)

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

zodict-1.3.1.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file zodict-1.3.1.tar.gz.

File metadata

  • Download URL: zodict-1.3.1.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zodict-1.3.1.tar.gz
Algorithm Hash digest
SHA256 899defbce47c2bc66abfe8d3efeb167ecc68a99923206672590a621c4e09352d
MD5 29264cd1e882c534d976bdb74659462c
BLAKE2b-256 b8b452bdda0f28de50b2a41e850d32825b5eb4bfa0dfae0a6b4f5cce812e047b

See more details on using hashes here.

Supported by

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