Skip to content

Commit c1bb119

Browse files
author
Alexander Smishlajev
committed
ShowDict: return True for any name if columns list is empty.
add vim modeline, trim trailing spaces.
1 parent d9cf123 commit c1bb119

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

roundup/cgi/templating.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"""
33

44
todo = '''
5-
- Most methods should have a "default" arg to supply a value
6-
when none appears in the hyperdb or request.
5+
- Most methods should have a "default" arg to supply a value
6+
when none appears in the hyperdb or request.
77
- Multilink property additions: change_note and new_upload
88
- Add class.find() too
99
- NumberHTMLProperty should support numeric operations
@@ -174,7 +174,7 @@ class RoundupPageTemplate(PageTemplate.PageTemplate):
174174
175175
- the url
176176
- the current index information (``filterspec``, ``filter`` args,
177-
``properties``, etc) parsed out of the form.
177+
``properties``, etc) parsed out of the form.
178178
- methods for easy filterspec link generation
179179
- *user*, the current user node as an HTMLItem instance
180180
- *form*, the current CGI form information as a FieldStorage
@@ -550,7 +550,7 @@ def classhelp(self, properties=None, label='(list)', width='500',
550550
height='400', property=''):
551551
''' Pop up a javascript window with class help
552552
553-
This generates a link to a popup window which displays the
553+
This generates a link to a popup window which displays the
554554
properties indicated by "properties" of the class named by
555555
"classname". The "properties" should be a comma-separated list
556556
(eg. 'id,name,description'). Properties defaults to all the
@@ -665,7 +665,7 @@ def designator(self):
665665
def is_retired(self):
666666
"""Is this item retired?"""
667667
return self._klass.is_retired(self._nodeid)
668-
668+
669669
def submit(self, label="Submit Changes"):
670670
"""Generate a submit button.
671671
@@ -715,7 +715,7 @@ def history(self, direction='descending', dre=re.compile('^\d+$')):
715715
id = self._klass.get(self._nodeid, prop_n, None)
716716
current[prop_n] = '<a href="%s%s">%s</a>'%(
717717
classname, id, current[prop_n])
718-
718+
719719
for id, evt_date, user, action, args in history:
720720
date_s = str(evt_date.local(timezone)).replace("."," ")
721721
arg_s = ''
@@ -1078,7 +1078,7 @@ def hyperlinked(self):
10781078

10791079
def plain(self, escape=0, hyperlink=0):
10801080
'''Render a "plain" representation of the property
1081-
1081+
10821082
- "escape" turns on/off HTML quoting
10831083
- "hyperlink" turns on/off in-text hyperlinking of URLs, email
10841084
addresses and designators
@@ -1190,7 +1190,7 @@ def field(self, size = 30):
11901190
return self.plain()
11911191

11921192
def confirm(self, size = 30):
1193-
''' Render a second form edit field for the property, used for
1193+
''' Render a second form edit field for the property, used for
11941194
confirmation that the user typed the password correctly. Generates
11951195
a field with name "@confirm@name".
11961196
@@ -1325,7 +1325,7 @@ def field(self, size=30):
13251325
if self.is_edit_ok():
13261326
value = '&quot;'.join(value.split('"'))
13271327
return self.input(name=self._formname,value=value,size=size)
1328-
1328+
13291329
return self.plain()
13301330

13311331
def reldate(self, pretty=1):
@@ -1491,9 +1491,9 @@ def menu(self, size=None, height=None, showid=0, additional=[],
14911491
if value is None:
14921492
s = 'selected="selected" '
14931493
l.append(_('<option %svalue="-1">- no selection -</option>')%s)
1494-
if linkcl.getprops().has_key('order'):
1494+
if linkcl.getprops().has_key('order'):
14951495
sort_on = ('+', 'order')
1496-
else:
1496+
else:
14971497
if sort_on is None:
14981498
sort_on = ('+', linkcl.labelprop())
14991499
else:
@@ -1548,7 +1548,7 @@ def __init__(self, *args, **kwargs):
15481548
fail_ok=1)
15491549
sortfun = make_sort_function(self._db, self._prop.classname)
15501550
self._value.sort(sortfun)
1551-
1551+
15521552
def __len__(self):
15531553
''' length of the multilink '''
15541554
return len(self._value)
@@ -1727,9 +1727,13 @@ class ShowDict:
17271727
''' A convenience access to the :columns index parameters
17281728
'''
17291729
def __init__(self, columns):
1730-
self.columns = {}
1731-
for col in columns:
1732-
self.columns[col] = 1
1730+
if columns:
1731+
self.columns = {}
1732+
for col in columns:
1733+
self.columns[col] = 1
1734+
else:
1735+
self.__getitem__ = lambda name: 1
1736+
17331737
def __getitem__(self, name):
17341738
return self.columns.has_key(name)
17351739

@@ -1863,7 +1867,7 @@ def _post_init(self):
18631867
def updateFromURL(self, url):
18641868
''' Parse the URL for query args, and update my attributes using the
18651869
values.
1866-
'''
1870+
'''
18671871
env = {'QUERY_STRING': url}
18681872
self.form = cgi.FieldStorage(environ=env)
18691873

@@ -2081,7 +2085,7 @@ def __getitem__(self, index):
20812085
if index < 0:
20822086
if index + self.end < self.first: raise IndexError, index
20832087
return self._sequence[index + self.end]
2084-
2088+
20852089
if index >= self.length:
20862090
raise IndexError, index
20872091

@@ -2143,3 +2147,4 @@ def html_quote(self, html):
21432147
'''HTML-quote the supplied text.'''
21442148
return cgi.escape(url)
21452149

2150+
# vim: set et sts=4 sw=4 :

0 commit comments

Comments
 (0)