docs: def _get_content_json(ident_hash=None):
      """Return a content as a dict from its ident-hash (uuid@version)."""
      request = get_current_request()
      routing_args = request and request.matchdict or {}
      if not ident_hash:
          ident_hash = routing_args['ident_hash']
  
      as_collated = asbool(request.GET.get('as_collated', True))
      page_ident_hash = routing_args.get('page_ident_hash', '')
      p_id, p_version = (None, None)
      if page_ident_hash:
          try:
              p_id, p_version = split_ident_hash(page_ident_hash)
          except IdentHashShortId as e:
              p_id = get_uuid(e.id)
              p_version = e.version
          except IdentHashMissingVersion as e:
              # page ident hash doesn't need a version
              p_id = e.id
              p_version = None
  
      id, version = split_ident_hash(ident_hash, containing=p_id)
  
      with db_connect() as db_connection:
          with db_connection.cursor() as cursor:
              result = get_content_metadata(id, version, cursor)
              # Build url for canonical link header
              result['canon_url'] = get_canonical_url(result, request)
  
              if result['mediaType'] == COLLECTION_MIMETYPE:
                  # Grab the collection tree.
                  result['tree'] = get_tree(ident_hash, cursor,
                                            as_collated=as_collated)
                  result['collated'] = as_collated
                  if not result['tree']:
                      # If collated tree is not available, get the uncollated
                      # tree.
                      result['tree'] = get_tree(ident_hash, cursor)
                      result['collated'] = False
  
                  if page_ident_hash:
                      for id_ in flatten_tree_to_ident_hashes(result['tree']):
                          id, version = split_ident_hash(id_)
                          if id == p_id and (
                             version == p_version or not p_version):
                              content = None
                              if as_collated:
                                  content = get_collated_content(
                                      id_, ident_hash, cursor)
                              if content:
                                  result = get_content_metadata(
                                      id, version, cursor)
                                  # Build url for canonical link header
                                  result['canon_url'] = (
                                          get_canonical_url(result, request))
                                  result['content'] = content[:]
                                  return result
                              # 302 'cause lack of baked content may be temporary
                              raise httpexceptions.HTTPFound(request.route_path(
                                  request.matched_route.name,
                                  _query=request.params,
                                  ident_hash=join_ident_hash(id, version),
                                  ext=routing_args['ext']),
                                  headers=[("Cache-Control",
                                            "max-age=60, public")])
                      raise httpexceptions.HTTPNotFound()
              else:
                  result = get_content_metadata(id, version, cursor)
                  # Build url for canonical link header
                  result['canon_url'] = get_canonical_url(result, request)
                  # Grab the html content.
                  args = dict(id=id, version=result['version'],
                              filename='index.cnxml.html')
                  cursor.execute(SQL['get-resource-by-filename'], args)
                  try:
                      content = cursor.fetchone()[0]
                  except (TypeError, IndexError,):  # None returned
                      logger.debug("module found, but "
                                   "'index.cnxml.html' is missing.")
                      raise httpexceptions.HTTPNotFound()
                  result['content'] = content[:]
  
      return result