Handle possible None values for obj when the element is optional

This commit is contained in:
Ozan Çağlayan
2010-02-04 08:25:43 +00:00
parent acd139a10d
commit 3e29e3cf5f
2 changed files with 20 additions and 6 deletions
+5
View File
@@ -1,3 +1,8 @@
2010-02-04 Ozan Çağlayan <ozan@pardus.org.tr>
* pisi/pxml/autoxml.py (format): Some optional elements may be None
during formatting, handle those situations. We still have a formatting
issue caused by the automagical output representation of autoxml.
2010-02-02 Ozan Çağlayan <ozan@pardus.org.tr>
* pisi/component.py(Maintainer): Add Maintainer tag to components.xml.
+15 -6
View File
@@ -727,11 +727,16 @@ class autoxml(oo.autosuper, oo.autoprop):
return obj.errors(where)
def format(obj, f, errs):
try:
obj.format(f, errs)
except Error:
if obj:
try:
obj.format(f, errs)
except Error:
if req == mandatory:
errs.append(_('Object cannot be formatted'))
else:
if req == mandatory:
errs.append(_('Mandatory argument not available'))
return (init, decode, encode, errors, format)
def gen_list_tag(cls, tag, spec):
@@ -841,9 +846,13 @@ class autoxml(oo.autosuper, oo.autoprop):
return obj.errors(where)
def format(obj, f, errs):
try:
obj.format(f, errs)
except Error:
if obj:
try:
obj.format(f, errs)
except Error:
if req == mandatory:
errs.append(_('Object cannot be formatted'))
else:
if req == mandatory:
errs.append(_('Mandatory argument not available'))