Handle possible None values for obj when the element is optional
This commit is contained in:
@@ -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
@@ -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'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user