Changes for larger data demo.

Add fields to search results
Put result() call inside try block - it's throwing an exception
Trap ADMINLIMIT and SIZELIMIT exceptions
This commit is contained in:
Kevin McCarthy
2007-08-28 09:20:12 -07:00
parent eebaa73d3d
commit ef2dc5cefa
4 changed files with 33 additions and 6 deletions

View File

@@ -145,7 +145,7 @@ class Root(controllers.RootController):
try:
users = client.find_users(uid.encode('utf-8'))
except ipaerror.IPAError, e:
turbogears.flash("User show failed: " + str(e))
turbogears.flash("User list failed: " + str(e))
raise turbogears.redirect("/userlist")
return dict(users=users, fields=forms.user.UserFields())

View File

@@ -15,7 +15,7 @@
</div>
<div py:if='users != None'>
<h2>Results</h2>
<table py:if='len(users) > 0'>
<table py:if='len(users) > 0' border="1">
<tr>
<th>
<label class="fieldlabel" py:content="fields.uid.label" />
@@ -23,13 +23,37 @@
<th>
Name
</th>
<th>
Phone
</th>
<th>
Unit
</th>
<th>
Title
</th>
<th>
License Plate
</th>
</tr>
<tr py:for="user in users">
<td>
<a href="${tg.url('/usershow',uid=user.uid)}">${user.uid}</a>
</td>
<td>
${user.cn}
${user.givenName} ${user.sn}
</td>
<td>
${user.telephoneNumber}
</td>
<td>
${user.ou}
</td>
<td>
${user.title}
</td>
<td>
${user.carLicense}
</td>
</tr>
</table>

View File

@@ -260,12 +260,12 @@ class IPAdmin(SimpleLDAPObject):
try:
res = self.search(*args)
type, obj = self.result(res)
# res = self.search_ext(args[0], args[1], filterstr=args[2], attrlist=args[3], serverctrls=sctrl)
except ldap.LDAPError, e:
raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
type, obj = self.result(res)
if not obj:
raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND,
"no such entry for " + str(args))
@@ -283,10 +283,13 @@ class IPAdmin(SimpleLDAPObject):
try:
res = self.search(*args)
type, obj = self.result(res)
except (ldap.ADMINLIMIT_EXCEEDED, ldap.SIZELIMIT_EXCEEDED), e:
raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR,
"Too many results returned by search", e)
except ldap.LDAPError, e:
raise ipaerror.gen_exception(ipaerror.LDAP_DATABASE_ERROR, None, e)
type, obj = self.result(res)
if not obj:
raise ipaerror.gen_exception(ipaerror.LDAP_NOT_FOUND,
"no such entry for " + str(args))

View File

@@ -385,7 +385,7 @@ class IPAServer:
# Assume the list of fields to search will come from a central
# configuration repository. A good format for that would be
# a comma-separated list of fields
search_fields_conf_str = "uid,givenName,sn,telephoneNumber"
search_fields_conf_str = "uid,givenName,sn,telephoneNumber,ou,carLicense,title"
search_fields = string.split(search_fields_conf_str, ",")
criteria = self.__safe_filter(criteria)