[387] | 1 | from Globals import InitializeClass |
---|
| 2 | from AccessControl import ClassSecurityInfo |
---|
| 3 | |
---|
| 4 | def createMultiColumnList(self,slist, numCols, sort_on='title_or_id'): |
---|
| 5 | try: |
---|
| 6 | mcl = self.createMultiColumnList(slist, numCols, sort_on=sort_on) |
---|
| 7 | return mcl |
---|
| 8 | except AttributeError: |
---|
| 9 | return [slist] |
---|
| 10 | |
---|
| 11 | class SortedDict(dict): |
---|
[1509] | 12 | """ A sorted dictionary. |
---|
| 13 | """ |
---|
[387] | 14 | security = ClassSecurityInfo() |
---|
[1313] | 15 | |
---|
| 16 | security.declarePublic('items') |
---|
[387] | 17 | def items(self): |
---|
[1313] | 18 | primary_metatags = self.pmt |
---|
[387] | 19 | lst = [(name,self[name]) for name in primary_metatags \ |
---|
| 20 | if name in self.keys()] + \ |
---|
| 21 | [(name, self[name]) for name in self.keys() \ |
---|
| 22 | if name not in primary_metatags] |
---|
| 23 | return lst |
---|
| 24 | |
---|
[1313] | 25 | |
---|
| 26 | security.declarePublic('__init__') |
---|
| 27 | def __init__(self, *args, **kwargs): |
---|
| 28 | super(SortedDict,self).__init__(*args, **kwargs) |
---|
| 29 | self.pmt = [] |
---|
| 30 | |
---|
| 31 | |
---|
| 32 | security.declarePublic('__setitem__') |
---|
| 33 | def __setitem__(self, i, y): |
---|
| 34 | super(SortedDict,self).__setitem__(i, y) |
---|
| 35 | if i not in self.pmt: |
---|
| 36 | self.pmt.append(i) |
---|
| 37 | |
---|
[1317] | 38 | security.declarePublic('pop') |
---|
| 39 | def pop(self, k, *args, **kwargs): |
---|
| 40 | super(SortedDict,self).pop(k, *args, **kwargs) |
---|
| 41 | if k in self.pmt: |
---|
| 42 | self.pmt.remove(k) |
---|
| 43 | |
---|
[387] | 44 | try: |
---|
| 45 | InitializeClass(SortedDict) |
---|
| 46 | except: |
---|
| 47 | pass |
---|