Check if attributes are not null before doing anything.

parent ea9da85d
...@@ -96,11 +96,23 @@ class SoftwareRelease(SlapDocument): ...@@ -96,11 +96,23 @@ class SoftwareRelease(SlapDocument):
def __getinitargs__(self): def __getinitargs__(self):
return (self._software_release, self._computer_guid, ) return (self._software_release, self._computer_guid, )
def getComputerId(self):
if not self._computer_guid:
raise NameError('computer_guid has not been defined.')
else:
return self._computer_guid
def getURI(self):
if not self._software_release:
raise NameError('software_release has not been defined.')
else:
return self._software_release
def error(self, error_log): def error(self, error_log):
# Does not follow interface # Does not follow interface
self._connection_helper.POST('/softwareReleaseError', { self._connection_helper.POST('/softwareReleaseError', {
'url': self._software_release, 'url': self.getURI(),
'computer_id' : self._computer_guid, 'computer_id' : self.getComputerId(),
'error_log': error_log}) 'error_log': error_log})
def getURI(self): def getURI(self):
...@@ -108,18 +120,18 @@ class SoftwareRelease(SlapDocument): ...@@ -108,18 +120,18 @@ class SoftwareRelease(SlapDocument):
def available(self): def available(self):
self._connection_helper.POST('/availableSoftwareRelease', { self._connection_helper.POST('/availableSoftwareRelease', {
'url': self._software_release, 'url': self.getURI(),
'computer_id': self._computer_guid}) 'computer_id': self.getComputerId()})
def building(self): def building(self):
self._connection_helper.POST('/buildingSoftwareRelease', { self._connection_helper.POST('/buildingSoftwareRelease', {
'url': self._software_release, 'url': self.getURI(),
'computer_id': self._computer_guid}) 'computer_id': self.getComputerId()})
def destroyed(self): def destroyed(self):
self._connection_helper.POST('/destroyedSoftwareRelease', { self._connection_helper.POST('/destroyedSoftwareRelease', {
'url': self._software_release, 'url': self.getURI(),
'computer_id': self._computer_guid}) 'computer_id': self.getComputerId()})
def getState(self): def getState(self):
return getattr(self, '_requested_state', 'available') return getattr(self, '_requested_state', 'available')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment