def _get_object(self, handle: str) -> Any:
     objects = {}
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['contact'] = WHOIS.get_contact_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['nsset'] = WHOIS.get_nsset_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['keyset'] = WHOIS.get_keyset_by_handle(handle)
     with suppress(OBJECT_NOT_FOUND, INVALID_HANDLE):
         objects['registrar'] = WHOIS.get_registrar_by_handle(handle)
     if not handle.startswith("."):
         with suppress(OBJECT_NOT_FOUND, UNMANAGED_ZONE, INVALID_LABEL,
                       TOO_MANY_LABELS, idna.IDNAError):
             idna_handle = idna.encode(handle).decode()
             try:
                 objects['domain'] = WHOIS.get_domain_by_handle(idna_handle)
             except OBJECT_DELETE_CANDIDATE:
                 objects['domain'] = None
     if not objects:
         raise WebwhoisError(
             code="OBJECT_NOT_FOUND",
             title=_("Record not found"),
             message=self.message_with_handle_in_html(
                 _("%s does not match any record."), handle),
             object_not_found=True,
         )
     return objects
Beispiel #2
0
 def _get_object(self, handle: str) -> Any:
     try:
         return WHOIS.get_nsset_by_handle(handle)
     except OBJECT_NOT_FOUND as error:
         raise WebwhoisError(
             'OBJECT_NOT_FOUND',
             title=_("Name server set not found"),
             message=self.message_with_handle_in_html(
                 _("No name server set matches %s handle."), handle),
         ) from error
     except INVALID_HANDLE as error:
         raise WebwhoisError(
             **self.message_invalid_handle(handle)) from error
Beispiel #3
0
 def load_registry_object(cls, context, handle):
     """Load nsset of the handle and append it into the context."""
     try:
         context[cls._registry_objects_key]["nsset"] = {
             "detail": WHOIS.get_nsset_by_handle(handle),
             "label": _("Nsset"),
         }
     except OBJECT_NOT_FOUND:
         context["server_exception"] = {
             "title":
             _("Name server set not found"),
             "message":
             cls.message_with_handle_in_html(
                 _("No name server set matches %s handle."), handle),
         }
     except INVALID_HANDLE:
         context["server_exception"] = cls.message_invalid_handle(handle)
Beispiel #4
0
 def load_registry_object(cls, context, handle):
     """Load nsset of the handle and append it into the context."""
     try:
         context[cls._registry_objects_key]["nsset"] = {
             "detail": WHOIS.get_nsset_by_handle(handle),
             "label": _("Nsset"),
         }
     except OBJECT_NOT_FOUND as error:
         raise WebwhoisError(
             'OBJECT_NOT_FOUND',
             title=_("Name server set not found"),
             message=cls.message_with_handle_in_html(
                 _("No name server set matches %s handle."), handle),
         ) from error
     except INVALID_HANDLE as error:
         raise WebwhoisError(
             **cls.message_invalid_handle(handle)) from error
Beispiel #5
0
 def load_related_objects(self, context):
     """Load objects related to the domain and append them into the context."""
     descriptions = self._get_status_descriptions(
         "domain", WHOIS.get_domain_status_descriptions)
     data = context[self._registry_objects_key][
         "domain"]  # detail, type, label, href
     if data is None:
         # Domain is a delete candidate
         return
     registry_object = data["detail"]
     data["status_descriptions"] = [
         descriptions[key] for key in registry_object.statuses
     ]
     if STATUS_DELETE_CANDIDATE in registry_object.statuses:
         return
     data.update({
         "registrant":
         WHOIS.get_contact_by_handle(registry_object.registrant_handle),
         "registrar":
         WHOIS.get_registrar_by_handle(registry_object.registrar_handle),
         "admins": [
             WHOIS.get_contact_by_handle(handle)
             for handle in registry_object.admin_contact_handles
         ],
     })
     if registry_object.nsset_handle:
         data["nsset"] = {
             "detail":
             WHOIS.get_nsset_by_handle(registry_object.nsset_handle)
         }
         NssetDetailMixin.append_nsset_related(data["nsset"])
     if registry_object.keyset_handle:
         data["keyset"] = {
             "detail":
             WHOIS.get_keyset_by_handle(registry_object.keyset_handle)
         }
         KeysetDetailMixin.append_keyset_related(data["keyset"])