Esempio n. 1
0
    def compute_index(self, doc):
        """Returns an iterator with (datatype, key, value) for each value be indexed."""
        index = common.flatten_dict(doc)

        # skip special values and /type/text
        skip = [
            "id",
            "key",
            "type.key",
            "revision",
            "latest_revison",
            "last_modified",
            "created",
        ]
        index = {
            (k, v)
            for k, v in index
            if k not in skip and not k.endswith(".value") and not k.endswith(".type")
        }

        for k, v in index:
            if k.endswith(".key"):
                yield 'ref', web.rstrips(k, ".key"), v
            elif isinstance(v, str):
                yield 'str', k, v
            elif isinstance(v, int):
                yield 'int', k, v
Esempio n. 2
0
    def compute_index(self, doc):
        key = doc['key']
        index = common.flatten_dict(doc)

        for k, v in index:
            # for handling last_modified.value
            if k.endswith(".value"):
                k = web.rstrips(k, ".value")

            if k.endswith(".key"):
                yield web.storage(key=key, datatype="ref", name=web.rstrips(k, ".key"), value=v)
            elif isinstance(v, basestring):
                yield web.storage(key=key, datatype="str", name=k, value=v)
            elif isinstance(v, int):
                yield web.storage(key=key, datatype="int", name=k, value=v)
Esempio n. 3
0
 def compute_index(self, doc):
     """Returns an iterator with (datatype, key, value) for each value be indexed.
     """
     index = common.flatten_dict(doc)
     
     # skip special values and /type/text
     skip = ["id", "key", "type.key", "revision", "latest_revison", "last_modified", "created"]
     index = set((k, v) for k, v in index if k not in skip and not k.endswith(".value") and not k.endswith(".type"))
     
     for k, v in index:
         if k.endswith(".key"):
             yield 'ref', web.rstrips(k, ".key"), v
         elif isinstance(v, basestring):
             yield 'str', k, v
         elif isinstance(v, int):
             yield 'int', k, v
Esempio n. 4
0
    def things(self, query):
        limit = query.pop('limit', 100)
        offset = query.pop('offset', 0)

        keys = set(self.docs)

        for k, v in query.items():
            if isinstance(v, dict):
                # query keys need to be flattened properly,
                # this corrects any nested keys that have been included
                # in values.
                flat = common.flatten_dict(v)[0]
                k += '.' + web.rstrips(flat[0], '.key')
                v = flat[1]
            keys = {k for k in self.filter_index(self.index, k, v) if k in keys}

        keys = sorted(keys)
        return keys[offset : offset + limit]
Esempio n. 5
0
 def index(self, doc):
     return common.flatten_dict(doc)
Esempio n. 6
0
 def index(self, doc):
     return common.flatten_dict(doc)