Introduction
This package provides a layer for storing key/value pairs. The storage can be configured dynamically by providing a IConfig adapter of the context on which the dict storage is used.
Examples
The adapter defaults to using a non-persistent dict:
>>> from ftw.dictstorage.interfaces import IDictStorage
>>> context = layer['example_context']
>>> print context
<ftw.dictstorage.testing.ExampleContext object at ...>
>>> storage = IDictStorage(context)
>>> storage['key'] = 'value'
>>> print storage['key']
value
>>> print storage.storage
{'key': 'value'}
>>> print IDictStorage(context).storage
{}
For configuring a custom storage, implement your own IConfig which uses custom IDictStorage:
>>> from ftw.dictstorage.interfaces import IConfig
>>> from ftw.dictstorage.base import DictStorage
>>> from zope.component import provideAdapter, adapts
>>> from zope.interface import Interface, alsoProvides, implements
>>> context = layer['example_context']
>>> class IMyContext(Interface):
... pass
>>> alsoProvides(context, IMyContext)
>>> class ContextStorageConfig(object):
... implements(IConfig)
... adapts(IMyContext)
...
... def __init__(self, context):
... self.context = context
...
... def get_storage(self):
... if not hasattr(self.context, '_dictstorage'):
... self.context._dictstorage = {}
... return self.context._dictstorage
>>> provideAdapter(ContextStorageConfig)
>>> class ContextDictStorage(DictStorage):
... implements(IDictStorage)
... adapts(IMyContext, IConfig)
...
... def __init__(self, context, config):
... self.context = context
... self.config = config
... self._storage = config.get_storage()
...
... @property
... def storage(self):
... return self._storage
...
>>> provideAdapter(ContextDictStorage)
>>> storage = IDictStorage(context)
>>> storage['foo'] = 'bar'
>>> print storage['foo']
bar
>>> print context._dictstorage
{'foo': 'bar'}
>>> print IDictStorage(context)['foo']
bar
Compatibility
Runs with Plone 4.2, 4.3, 5.1.
Links
Continuous integration: https://jenkins.4teamwork.ch/search?q=ftw.dictstorage
Copyright
This package is copyright by 4teamwork.
ftw.dictstorage is licensed under GNU General Public License, version 2.
Changelog
1.3.0 (2019-11-11)
Drop support for Plone 4.0 and 4.1. [jone]
Add support for Plone 5.1 [Nachtalb]
1.2 (2012-06-05)
Declare zope dependencies. [jone]
Update README. [jone]
1.1 (2012-03-28)
Remove “self” from IDictStorage interface definitions. This makes it possible to validate a implementation with verifyClass. [jone]
1.0 (2011-11-17)
added test-buildout for plone 4.1 [eschmutz]
1.0a4 (2011-07-12)
Fixed signature of some class methods [lgraf]
1.0a3
1.0a2
Metadata
Release files for ftw.dictstorage 1.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ftw.dictstorage-1.3.0.tar.gz | 12.5 kB | Without provenance | Details for ftw.dictstorage-1.3.0.tar.gz |
Release files / ftw.dictstorage-1.3.0.tar.gz
| Download URL | ftw.dictstorage-1.3.0.tar.gz |
|---|---|
| Size | 12.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68001b84383b5e71f64d3d1a4157a19b7d67bb40051cc411862d074d4e7149f3
|
|
BLAKE2b-256 checksum How to use checksums |
aa11a800593ca0d15f3eda5ff915a1524314e271605f9a0ecbd6c18a18dd2556
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.30.0 CPython/2.7.15
|
Security for ftw.dictstorage 1.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.