[Da-tools-commits] ./da-tools/userdir-ldap-cgi-python r15: adding the search stuff in the controller but not in the machines template
Robin Wittler
real at geek-at-work.org
Sun Jan 25 19:50:15 UTC 2009
------------------------------------------------------------
revno: 15
committer: Robin Wittler <real at geek-at-work.org>
branch nick: userdir-ldap-cgi-python
timestamp: Sun 2009-01-25 20:50:15 +0100
message:
adding the search stuff in the controller but not in the machines template
adding unicode type check in the sortResults method
modified:
ud_ldap_ng/controllers/udldapng.py
ud_ldap_ng/lib/libldap.py
ud_ldap_ng/templates/machines.html
-------------- next part --------------
=== modified file 'ud_ldap_ng/controllers/udldapng.py'
--- a/ud_ldap_ng/controllers/udldapng.py 2009-01-25 18:00:02 +0000
+++ b/ud_ldap_ng/controllers/udldapng.py 2009-01-25 19:50:15 +0000
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
-__version__ = '0.0.3'
+__version__ = '0.0.4'
__author__ = 'Robin Wittler <real at geek-at-work.org>'
__license__ = 'GPL3'
@@ -20,8 +20,15 @@
def index(self):
con = AnonymousDebianLDAP()
c.attributes = ['hostname', 'architecture', 'purpose', 'sponsor', 'status']
+ c.sortorders = {'asc': False, 'dsc': True}
c.result = con.getDebianHosts(attrlist=c.attributes, adjust=True, default_value='')
- sortby = request.params.get('sortby', None)
- if not sortby or sortby not in c.attributes:
- c.result = c.result.sortResults('hostname')
+ c.sortorder = request.params.get('sortorder', None)
+ if not c.sortorder or c.sortorder not in c.sortorders:
+ c.sortorder = c.sortorders.get('asc')
+ else:
+ c.sortorder = c.sortorders.get(c.sortorder)
+ c.sortby = request.params.get('sortby', None)
+ if not c.sortby or c.sortby not in c.attributes:
+ c.sortby = 'hostname'
+ c.results = c.result.sortResults(c.sortby, reverse=c.sortorder)
return render('/machines.html')
=== modified file 'ud_ldap_ng/lib/libldap.py'
--- a/ud_ldap_ng/lib/libldap.py 2009-01-25 18:00:02 +0000
+++ b/ud_ldap_ng/lib/libldap.py 2009-01-25 19:50:15 +0000
@@ -1,6 +1,6 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
-__version__ = '0.0.5'
+__version__ = '0.0.6'
__author__ = 'Robin Wittler <real at geek-at-work.org>'
__license__ = 'GPL3'
@@ -142,8 +142,8 @@
@return iterator
'''
#TODO: This is all a bit ugly, please show me a better way to sort many dicts by one key. ;)
- if not type(keyword) == str:
- raise TypeError('keyword must be type str, None or False')
+ if not type(keyword) == str and not type(keyword) == unicode:
+ raise TypeError('keyword must be type str or unicode str')
if not keyword in cls.getAllAttrFromResults(cls.__results):
raise KeyError('keyword exist not in results')
if not type(reverse) == bool:
=== modified file 'ud_ldap_ng/templates/machines.html'
--- a/ud_ldap_ng/templates/machines.html 2009-01-25 18:00:02 +0000
+++ b/ud_ldap_ng/templates/machines.html 2009-01-25 19:50:15 +0000
@@ -49,7 +49,7 @@
<th>Status</th>
</tr>
<%! from ud_ldap_ng.lib.libformat import is_markup_string, is_public, map_chars %>
- % for result in c.result:
+ % for result in c.results:
<tr>
<td>
% for hostname in result.get('hostname', ['Unkown',]):
More information about the Da-tools-commits
mailing list