[Commits] (jeffrey) Return empty string for non-existent attributes
when displaying Contacts
commits at osafoundation.org
commits at osafoundation.org
Mon Mar 8 09:31:58 PST 2004
Commit by: jeffrey
Modified files:
osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py 1.4 1.5
Log message:
Return empty string for non-existent attributes when displaying Contacts
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py.diff?r1=text&tr1=1.4&r2=text&tr2=1.5
Index: osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py
diff -u osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py:1.4 osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py:1.5
--- osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py:1.4 Wed Mar 3 15:38:24 2004
+++ osaf/chandler/Chandler/parcels/OSAF/views/content/Content.py Mon Mar 8 09:31:27 2004
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.4 $"
-__date__ = "$Date: 2004/03/03 23:38:24 $"
+__version__ = "$Revision: 1.5 $"
+__date__ = "$Date: 2004/03/08 17:31:27 $"
__copyright__ = "Copyright (c) 2003 Open Source Applications Foundation"
__license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
@@ -65,21 +65,33 @@
class ContactListDelegate(ControlBlocks.ListDelegate):
- def ElementText (self, index, column):
+ def valOrEmpty(self, element, attrList):
+ if len(attrList)==0:
+ return element
+ attr=attrList[0]
+ if element.hasAttributeValue(attr):
+ if element.getAttributeAspect(attr, "cardinality") == "single":
+ r=element.getAttributeValue(attr)
+ else:
+ r=element.getAttributeValue(attr).first()
+ return self.valOrEmpty(r, attrList[1:])
+ else:
+ return ""
+
+ def ElementText (self, index, column):
counterpart = Globals.repository.find (self.counterpartUUID)
result = counterpart.contentSpec.indexResult (index)
if column == 0:
- return result.contactName.firstName
+ return self.valOrEmpty(result, ("contactName", "firstName"))
elif column == 1:
- return result.contactName.lastName
+ return self.valOrEmpty(result, ("contactName", "lastName"))
elif column == 2:
- return result.homeSection.phoneNumbers.first().phoneNumber
+ return self.valOrEmpty(result, ("homeSection", "phoneNumbers", "phoneNumber"))
elif column == 3:
- return result.homeSection.emailAddresses.first().emailAddress
+ return self.valOrEmpty(result, ("homeSection", "emailAddresses", "emailAddress"))
elif __debug__:
assert False, "Bad column"
return ""
-
class MixedListDelegate(ControlBlocks.ListDelegate):
def ElementText (self, index, column):
More information about the Commits
mailing list