Exemple #1
0
    def save_many(self,
                  docs,
                  timestamp,
                  comment,
                  data,
                  ip,
                  author,
                  action=None):
        docs = list(docs)
        action = action or "bulk_update"
        logger.debug(
            "saving %d docs - %s",
            len(docs),
            dict(
                timestamp=timestamp,
                comment=comment,
                data=data,
                ip=ip,
                author=author,
                action=action,
            ),
        )

        s = SaveImpl(self.db, self.schema, self.indexer, self.property_manager)

        # Hack to allow processing of json data before using. Required for OL legacy.
        s.process_json = process_json

        docs = common.format_data(docs)
        changeset = s.save(
            docs,
            timestamp=timestamp,
            comment=comment,
            ip=ip,
            author=author,
            action=action,
            data=data,
        )

        # update cache.
        # Use the docs from result as they contain the updated revision and last_modified fields.
        for doc in changeset.get('docs', []):
            web.ctx.new_objects[doc['key']] = json.dumps(doc)

        return changeset
Exemple #2
0
 def reindex(self, keys):
     s = SaveImpl(self.db, self.schema, self.indexer, self.property_manager)
     # Hack to allow processing of json before using. Required for OL legacy.
     s.process_json = process_json
     return s.reindex(keys)