Generalize content_get_partition to other object types
This will be used by swh-scrubber to support both postgresql and cassandra without backend-specific code (swh-scrubber#4685 (closed)).
It should also make it easier to add Cassandra support to swh.storage.backfill.