code: def prepare(cls, session, pkgen, items):
          
          for item in cls.merge(session, items):
              if hasattr(item, "id"):
                  item.id.resolve(id=pkgen.get(cls), is_new=True)
              yield cls.to_dict(item)
docs: This is called immediately before the items are written to the
          database. pkgen is passed in to allow last-minute resolving of ids.