• Kirill Smelkov's avatar
    demo: URI resolver · 2f02bc90
    Kirill Smelkov authored
    This patch adds `demo:` URI scheme to create DemoStorage from an URI.
    
    While several existing resolvers already handle ?demostorage argument to
    wrap itself with DemoStorage and in-RAM MappingStorage for changes, this
    approach has the following drawbacks:
    
    - every resolver must do it
    - it is not possible to create DemoStorage with non-MappingStorage for changes.
    
    My particular motivation here is Wendelin.core 2: it spawn WCFS
    filesystem server to serve array data from ZODB storage, and passes
    storage URL to spawned wcfs process, so that wcfs could connect and
    retrieve data from the same ZODB storage that client process is
    using. When original ERP5 client is using DemoStorage, both `base` and
    `changes` must be persisted because if changes would be in-RAM
    MappingStorage, WCFS could not access that data because it runs as a
    separate process.
    
    To build a DemoStorage URI we follow XRI Cross-references approach to
    embed URIs for base and changes into combining demo URI:
    
        demo:(base_uri)/(δ_uri)
    
    https://en.wikipedia.org/wiki/Extensible_Resource_Identifier provides
    some related details and examples.
    
    I choose fragments as the place for ZODB.DB arguments:
    
        demo:(base_uri)/(δ_uri)#dbkw...
    
    The reason fragments - instead of parameters - are used, is because
    DB arguments are _local_. Even with different DB arguments the URI
    refers to the same storage, and for wendelin.core 2 it is important to
    be able to determine whether two client processes actually use the same
    underlying ZODB storage, even if those two clients use different local
    parameters, like connection_pool_size and similar. Keeping such local
    arguments in fragments makes it easy to determine the underlying URI of
    the storage - by dropping fragments. It also follows logic from RFC 3986,
    which says that "fragment ... may be ... some view on representations of
    the primary resource": https://tools.ietf.org/html/rfc3986#section-3.5
    
    Thanks beforehand,
    Kirill
    
    /cc @tseaver, @azmeuk, @jimfulton
    
    P.S.
    
    It was already suggested several times to add DemoStorageURIResolver and
    deprecate ?demostorage in existing URI resolvers:
    
    https://github.com/Pylons/zodburi/pull/25#issuecomment-485506959
    https://github.com/Pylons/zodburi/pull/25#issuecomment-511480572
    https://github.com/Pylons/zodburi/pull/25#issuecomment-622931793
    2f02bc90
setup.py 2.22 KB