Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Internet > Plone Extensions

    ftw.dictstorage 1.2

    Download button

    No screenshots available
    Downloads: 87  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Rok Garbas | More programs
    GPL / FREE
    June 5th, 2012, 13:25 GMT [view history]
    ROOT / Internet / Plone Extensions

     Read user reviews (0)  Refer to a friend  Subscribe

    ftw.dictstorage description

    Provides a layer for storing key / value paires

    ftw.dictstorage is a Plone product that provides a layer for storing key / value paires. The storage can be configured dinamically 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



    Product's homepage

    Requirements:

    · Python
    · Plone CMS

    What's New in This Release: [ read full changelog ]

    · Declare zope dependencies. [jone]
    · Update README. [jone]

      


    TAGS:

    key paires | value paires | Plone | key | value

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM