i2mint / py2store

Tools to create simple and consistent interfaces to complicated and varied data sources.
MIT License
11 stars 2 forks source link

.items() not working with non-static `key_of_id` with `wrap_kvs` #65

Closed thorwhalen closed 4 years ago

thorwhalen commented 4 years ago

In ut.util.code.findimports, the wrapping of ModuleImports below made .items() not work.

def modobj_to_modname(self, modobj):
    return self.store._modules[modobj]

def modname_to_modobj(self, modname):
    return self.store._modobj_of_modname[modname]

@wrap_kvs(name='ModuleImports', key_of_id=modobj_to_modname, id_of_key=modname_to_modobj, __module__=__name__)
class ModuleImports(ModuleImportsBase):
    @staticmethod
    def _key_to_val(k):
        return k.imports
thorwhalen commented 4 years ago

Was a bug in the particular store that was wrapped, not the wrap_kvs mechanism