author | Lennard de Rijk <ljvderijk@gmail.com> |
Mon, 01 Jun 2009 20:03:22 +0200 | |
changeset 2372 | f1cbafd21f75 |
parent 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', |
2108
286aa6528e84
Properly handle exports when there are multiple lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1807
diff
changeset
|
42 |
'idx', |
539
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 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
45 |
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
|
46 |
"""Constructs a new Lists object with the specified contents. |
539
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 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
49 |
# 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
|
50 |
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
|
51 |
self._content = {} |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
# 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
|
54 |
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
|
55 |
self._list_data = [] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
57 |
# 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
|
58 |
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
|
59 |
self._row_data = [] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
60 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
61 |
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
|
62 |
"""Delegate field lookup to the current list if appropriate. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
63 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
64 |
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
|
65 |
DEF_PASSTHROUGH_FIELDS, and the current list defines this field, |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
66 |
the value from the current list is returned. |
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 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
69 |
if attr not in self.DEF_PASSTHROUGH_FIELDS: |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
raise AttributeError() |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
71 |
|
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
|
72 |
if attr not in self._content: |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
73 |
raise AttributeError() |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
75 |
return self.get(attr) |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
76 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
77 |
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
|
78 |
"""Returns the item for the current list data. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
79 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
80 |
|
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
|
81 |
return self._content[item] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
82 |
|
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
|
83 |
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
|
84 |
"""Shifts out the current list content. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
85 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
86 |
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
|
87 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
88 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
89 |
# 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
|
90 |
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
|
91 |
self._contents = self._contents[1:] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
92 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
93 |
# 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
|
94 |
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
|
95 |
self._rows = range(len(self._list_data)) |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
96 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
97 |
return self.get('main') |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
98 |
|
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
|
99 |
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
|
100 |
"""Returns the next list row for the current list. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
101 |
|
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
|
102 |
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
|
103 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
104 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
105 |
# 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
|
106 |
self._row_data = self._list_data[0] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
107 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
108 |
# 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
|
109 |
self._list_data = self._list_data[1:] |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
110 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
111 |
return self.get('row') |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
112 |
|
1458
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
113 |
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
|
114 |
"""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
|
115 |
""" |
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
116 |
|
ec06d3ee73e4
Make it possible to display a message when there are no lists
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1308
diff
changeset
|
117 |
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
|
118 |
|
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
119 |
def lists(self): |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
"""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
|
121 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
122 |
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
|
123 |
without using a while loop. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
124 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
125 |
|
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
|
126 |
return self._lists |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
127 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
128 |
def rows(self): |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
129 |
"""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
|
130 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
131 |
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
|
132 |
the current list, without using a while loop. |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
|
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
|
135 |
return self._rows |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
136 |
|
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
137 |
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
|
138 |
"""Returns the current row item for the current list. |
539
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
139 |
|
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
|
140 |
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
|
141 |
""" |
e30462354e26
Allow for multiple list objects
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
142 |
|
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
|
143 |
return self._row_data |
553
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
144 |
|
1679
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
145 |
def info(self): |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
146 |
"""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
|
147 |
""" |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
148 |
|
1803
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
149 |
if 'info' not in self._content: |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
150 |
return "" |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
151 |
|
1679
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
152 |
action, args = self.get('info') |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
153 |
return action(self._row_data, args) |
2b28763da7a4
Add item info to the list iterator
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1458
diff
changeset
|
154 |
|
553
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
155 |
def redirect(self): |
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
156 |
"""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
|
157 |
""" |
c0cc20b4afc9
Make redirect generic using the new Lists object
Sverre Rabbelier <srabbelier@gmail.com>
parents:
539
diff
changeset
|
158 |
|
1803
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
159 |
if 'action' not in self._content: |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
160 |
return "" |
d516eb26985e
Return "" when there is no info/action set
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1679
diff
changeset
|
161 |
|
560
a32be584ee04
Requests are almost working now
Sverre Rabbelier <srabbelier@gmail.com>
parents:
553
diff
changeset
|
162 |
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
|
163 |
return action(self._row_data, args) |