Skip to content
This repository has been archived by the owner on Dec 28, 2017. It is now read-only.

Commit

Permalink
Minor tweaks to deletion protection.
Browse files Browse the repository at this point in the history
  • Loading branch information
gtaylor committed Nov 4, 2012
1 parent f2a22d1 commit 0b1bc6f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
17 changes: 13 additions & 4 deletions route53/hosted_zone.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@ def delete(self, force=False):
the request. the request.
""" """


if self._is_deleted: self._halt_if_already_deleted()
raise AlreadyDeletedError('HostedZone is already deleted.')


if force: if force:
# Forcing deletion by cleaning up all record sets first. We'll # Forcing deletion by cleaning up all record sets first. We'll
Expand All @@ -117,6 +116,17 @@ def delete(self, force=False):


return retval return retval


def _halt_if_already_deleted(self):
"""
Convenience method used to raise an AlreadyDeletedError exception if
this HostedZone has been deleted.
:raises: AlreadyDeletedError
"""

if self._is_deleted:
raise AlreadyDeletedError("Can't manipulate a deleted zone.")

def add_a_record(self, name, values, ttl=60): def add_a_record(self, name, values, ttl=60):
""" """
Adds an A record to the hosted zone. Adds an A record to the hosted zone.
Expand All @@ -129,8 +139,7 @@ def add_a_record(self, name, values, ttl=60):
``rrset`` is the newly created AResourceRecordSet instance. ``rrset`` is the newly created AResourceRecordSet instance.
""" """


if self._is_deleted: self._halt_if_already_deleted()
raise AlreadyDeletedError("Can't add records to a deleted HostedZone.")


rrset = AResourceRecordSet( rrset = AResourceRecordSet(
connection=self.connection, connection=self.connection,
Expand Down
3 changes: 2 additions & 1 deletion route53/resource_record_set.py
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ def hosted_zone(self):


def is_modified(self): def is_modified(self):
""" """
Determines whether this record set has been modified since retrieval. Determines whether this record set has been modified since the
last retrieval or save.
:rtype: bool :rtype: bool
:returns: ``True` if the record set has been modified, :returns: ``True` if the record set has been modified,
Expand Down

0 comments on commit 0b1bc6f

Please sign in to comment.