|
15 | 15 | # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
16 | 16 | # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
17 | 17 | # |
18 | | -# $Id: hyperdb.py,v 1.33 2001-11-21 03:40:54 richard Exp $ |
| 18 | +# $Id: hyperdb.py,v 1.34 2001-11-21 04:04:43 richard Exp $ |
19 | 19 |
|
20 | 20 | # standard python modules |
21 | 21 | import cPickle, re, string |
@@ -680,17 +680,28 @@ def sortfun(a, b, sort=sort, group=group, properties=self.getprops(), |
680 | 680 | # sort by group and then sort |
681 | 681 | for list in group, sort: |
682 | 682 | for dir, prop in list: |
683 | | - # handle the properties that might be "faked" |
684 | | - if not an.has_key(prop): |
685 | | - an[prop] = cl.get(a_id, prop) |
686 | | - av = an[prop] |
687 | | - if not bn.has_key(prop): |
688 | | - bn[prop] = cl.get(b_id, prop) |
689 | | - bv = bn[prop] |
690 | | - |
691 | 683 | # sorting is class-specific |
692 | 684 | propclass = properties[prop] |
693 | 685 |
|
| 686 | + # handle the properties that might be "faked" |
| 687 | + # also, handle possible missing properties |
| 688 | + try: |
| 689 | + if not an.has_key(prop): |
| 690 | + an[prop] = cl.get(a_id, prop) |
| 691 | + av = an[prop] |
| 692 | + except KeyError: |
| 693 | + # the node doesn't have a value for this property |
| 694 | + if isinstance(propclass, Multilink): av = [] |
| 695 | + else: av = '' |
| 696 | + try: |
| 697 | + if not bn.has_key(prop): |
| 698 | + bn[prop] = cl.get(b_id, prop) |
| 699 | + bv = bn[prop] |
| 700 | + except KeyError: |
| 701 | + # the node doesn't have a value for this property |
| 702 | + if isinstance(propclass, Multilink): bv = [] |
| 703 | + else: bv = '' |
| 704 | + |
694 | 705 | # String and Date values are sorted in the natural way |
695 | 706 | if isinstance(propclass, String): |
696 | 707 | # clean up the strings |
@@ -849,6 +860,9 @@ def Choice(name, *options): |
849 | 860 |
|
850 | 861 | # |
851 | 862 | # $Log: not supported by cvs2svn $ |
| 863 | +# Revision 1.33 2001/11/21 03:40:54 richard |
| 864 | +# more new property handling |
| 865 | +# |
852 | 866 | # Revision 1.32 2001/11/21 03:11:28 richard |
853 | 867 | # Better handling of new properties. |
854 | 868 | # |
|
0 commit comments