code: def retrieve_version(self, obj, version):
          
          current_version = getattr(obj, VERSION_ID, None)
  
          if current_version is None:
              # No initial version
              return obj
  
          if str(current_version) == str(version):
              # Same version
              return obj
  
          # Retrieve the object from the repository
          pr = api.get_tool("portal_repository")
          # bypass permission check to AccessPreviousVersions
          result = pr._retrieve(
              obj, selector=version, preserve=(), countPurged=True)
          return result.object
docs: Retrieve the version of the object