author | Lennard de Rijk <ljvderijk@gmail.com> |
Mon, 16 Mar 2009 15:33:27 +0000 | |
changeset 1889 | 4356a9201d20 |
parent 1807 | 1f8cde169f32 |
child 2108 | 286aa6528e84 |
permissions | -rw-r--r-- |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
17 |
"""List generation logic. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
class Lists(object): |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
26 |
"""List array suitable for enumerating over with just 'for in'. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
29 |
DEF_PASSTHROUGH_FIELDS = [ |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
'pagination', |
572
1b3e7280743a
Made list pagination part of Lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
560
diff
changeset
|
31 |
'pagination_form', |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
'description', |
1807
1f8cde169f32
Add an export link to all list views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1803
diff
changeset
|
33 |
'export', |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
34 |
'heading', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
'row', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
'limit', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
'newest', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
'prev', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
39 |
'next', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
'first', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
'last', |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
] |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
def __init__(self, contents): |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
45 |
"""Constructs a new Lists object with the specified contents. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
# All the contents of all the lists |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
49 |
self._contents = contents |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
50 |
self._content = {} |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
# For iterating over all the lists |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
53 |
self._lists = range(len(contents)) |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
54 |
self._list_data = [] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
# For iterating over the rows |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
57 |
self._rows = [] |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
58 |
self._row_data = [] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
def __getattr__(self, attr): |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
61 |
"""Delegate field lookup to the current list if appropriate. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
62 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
If, and only if, a lookup is done on one of the fields defined in |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
DEF_PASSTHROUGH_FIELDS, and the current list defines this field, |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
65 |
the value from the current list is returned. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
67 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
68 |
if attr not in self.DEF_PASSTHROUGH_FIELDS: |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
raise AttributeError() |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
71 |
if attr not in self._content: |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
raise AttributeError() |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
return self.get(attr) |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
def get(self, item): |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
77 |
"""Returns the item for the current list data. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
78 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
80 |
return self._content[item] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
81 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
82 |
def nextList(self): |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
83 |
"""Shifts out the current list content. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
84 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
85 |
The main content of the next list is returned for further processing. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
87 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
# Advance the list data once |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
89 |
self._content = self._contents[0] |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
90 |
self._contents = self._contents[1:] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
91 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
# Update internal 'iterators' |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
93 |
self._list_data = self.get('data') |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
94 |
self._rows = range(len(self._list_data)) |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
95 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
return self.get('main') |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
98 |
def nextRow(self): |
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
99 |
"""Returns the next list row for the current list. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
100 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
101 |
Before calling this method, nextList should be called at least once. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
102 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
103 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
# Update internal 'iterators' |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
105 |
self._row_data = self._list_data[0] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
106 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
# Advance the row data once |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
108 |
self._list_data = self._list_data[1:] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
109 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
110 |
return self.get('row') |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
|
1458
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
112 |
def empty(self): |
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
113 |
"""Returns true iff there are no lists |
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
114 |
""" |
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
115 |
|
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
116 |
return not self._lists |
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
117 |
|
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
def lists(self): |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
"""Returns a list of numbers the size of the amount of lists. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
121 |
This method can be used to iterate over all lists with shift, |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
without using a while loop. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
123 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
124 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
125 |
return self._lists |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
126 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
def rows(self): |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
"""Returns a list of numbers the size of the amount of items. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
130 |
This method can be used to iterate over all items with next for |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
131 |
the current list, without using a while loop. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
132 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
134 |
return self._rows |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
135 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
def item(self): |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
137 |
"""Returns the current row item for the current list. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
138 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
139 |
Before calling this method, nextRow should be called at least once. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
140 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
141 |
|
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
142 |
return self._row_data |
553
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
143 |
|
1679
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
144 |
def info(self): |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
145 |
"""Returns additional info on the current row item in the current list. |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
146 |
""" |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
147 |
|
1803
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
148 |
if 'info' not in self._content: |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
149 |
return "" |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
150 |
|
1679
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
151 |
action, args = self.get('info') |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
152 |
return action(self._row_data, args) |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
153 |
|
553
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
154 |
def redirect(self): |
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
155 |
"""Returns the redirect for the current row item in the current list. |
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
156 |
""" |
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
157 |
|
1803
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
158 |
if 'action' not in self._content: |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
159 |
return "" |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
160 |
|
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
553
diff
changeset
|
161 |
action, args = self.get('action') |
625
ec867361b5ba
Add missing dots in soc.logic.lists module. Change method names to comply with Style Guide. Make class variable protected by adding "_" to the name of variable. Update lists templates respectively (methods name change).
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
572
diff
changeset
|
162 |
return action(self._row_data, args) |