def primary_key(self):
    """Returns either the primary key value, or a tuple containing the primary key values in the
    case of a composite primary key.
    """
    pkname = self.primary_key_name
    if pkname is None:
      return None
    elif isinstance(pkname, str):
      return getattr(self, pkname)
    else:
      return tuple((getattr(self, pkn) for pkn in pkname))
Returns either the primary key value, or a tuple containing the primary key values in the
    case of a composite primary key.