Fix assigning values to error stanzas.

The new data interfaces were deleting the actual error conditions if
they were set afterward with falsy data.
This commit is contained in:
Lance Stout 2012-06-19 16:21:34 -07:00
parent 433ee08687
commit 019a4b20ae
2 changed files with 9 additions and 3 deletions

View file

@ -143,15 +143,19 @@ class Error(ElementBase):
return self._get_sub_text('{%s}redirect' % self.condition_ns, '') return self._get_sub_text('{%s}redirect' % self.condition_ns, '')
def set_gone(self, value): def set_gone(self, value):
del self['condition']
if value: if value:
del self['condition']
return self._set_sub_text('{%s}gone' % self.condition_ns, value) return self._set_sub_text('{%s}gone' % self.condition_ns, value)
elif self['condition'] == 'gone':
del self['condition']
def set_redirect(self, value): def set_redirect(self, value):
del self['condition']
if value: if value:
del self['condition']
ns = self.condition_ns ns = self.condition_ns
return self._set_sub_text('{%s}redirect' % ns, value) return self._set_sub_text('{%s}redirect' % ns, value)
elif self['condition'] == 'redirect':
del self['condition']
def del_gone(self): def del_gone(self):
self._del_sub('{%s}gone' % self.condition_ns) self._del_sub('{%s}gone' % self.condition_ns)

View file

@ -72,10 +72,12 @@ class StreamError(Error, StanzaBase):
return self._get_sub_text('{%s}see-other-host' % ns, '') return self._get_sub_text('{%s}see-other-host' % ns, '')
def set_see_other_host(self, value): def set_see_other_host(self, value):
del self['condition']
if value: if value:
del self['condition']
ns = self.condition_ns ns = self.condition_ns
return self._set_sub_text('{%s}see-other-host' % ns, value) return self._set_sub_text('{%s}see-other-host' % ns, value)
elif self['condition'] == 'see-other-host':
del self['condition']
def del_see_other_host(self): def del_see_other_host(self):
self._del_sub('{%s}see-other-host' % self.condition_ns) self._del_sub('{%s}see-other-host' % self.condition_ns)