Fix the none error

The object is None. But we still get the property of the object.

Change-Id: I6cdc99b31c92f616b2cd47b28b16191d594b7783
This commit is contained in:
chenying 2016-10-10 20:32:39 +08:00
parent 1a8adb3014
commit 404d8d2d32
2 changed files with 3 additions and 5 deletions

View File

@ -203,8 +203,7 @@ class ProtectablesController(wsgi.Controller):
protectable_id = instance.get("id")
instance["type"] = protectable_type
if protectable_id is None:
raise exception.InvalidProtectableInstance(
protectable_id=protectable_id)
raise exception.InvalidProtectableInstance()
dependents = self.protection_api.\
list_protectable_dependents(context, protectable_id,
protectable_type)
@ -266,8 +265,7 @@ class ProtectablesController(wsgi.Controller):
show_protectable_instance(context, protectable_type,
protectable_id)
if instance is None:
raise exception.InvalidProtectableInstance(
protectable_id=instance.get('id'))
raise exception.InvalidProtectableInstance()
dependents = self.protection_api.\
list_protectable_dependents(context, protectable_id,

View File

@ -185,7 +185,7 @@ class InvalidContentType(Invalid):
class InvalidProtectableInstance(Invalid):
message = _("Invalid protectable instance %(protectable_id)s.")
message = _("Invalid protectable instance.")
class PasteAppNotFound(NotFound):