code: def preprocess_record(self, pid, record, links_factory=None, **kwargs):
          
          links_factory = links_factory or (lambda x, record=None, **k: dict())
          metadata = copy.deepcopy(record.replace_refs()) if self.replace_refs \
              else record.dumps()
          return dict(
              pid=pid,
              metadata=metadata,
              links=links_factory(pid, record=record, **kwargs),
              revision=record.revision_id,
              created=(pytz.utc.localize(record.created).isoformat()
                       if record.created else None),
              updated=(pytz.utc.localize(record.updated).isoformat()
                       if record.updated else None),
          )
docs: Prepare a record and persistent identifier for serialization.