<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[14122] CalendarServer/trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/14122">14122</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2014-10-29 13:28:29 -0700 (Wed, 29 Oct 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>csmp --search now can use multiple tokens; adds --context for limiting record types</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertoolsprincipalspy">CalendarServer/trunk/calendarserver/tools/principals.py</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolstestprincipalsusersgroupsxml">CalendarServer/trunk/calendarserver/tools/test/principals/users-groups.xml</a></li>
<li><a href="#CalendarServertrunkcalendarservertoolstesttest_principalspy">CalendarServer/trunk/calendarserver/tools/test/test_principals.py</a></li>
<li><a href="#CalendarServertrunktxdavwhogroupspy">CalendarServer/trunk/txdav/who/groups.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertoolsprincipalspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/principals.py (14121 => 14122)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/principals.py        2014-10-29 16:57:26 UTC (rev 14121)
+++ CalendarServer/trunk/calendarserver/tools/principals.py        2014-10-29 20:28:29 UTC (rev 14122)
</span><span class="lines">@@ -71,7 +71,8 @@
</span><span class="cx"> print(" -v --verbose: print debugging information")
</span><span class="cx"> print("")
</span><span class="cx"> print("actions:")
</span><del>- print(" --search <search-string>: search for matching principals")
</del><ins>+ print(" --context <search-context>: {user|group|location|resource|attendee}; must be used in conjunction with --search")
+ print(" --search <search-tokens>: search using one or more tokens")
</ins><span class="cx"> print(" --list-principal-types: list all of the known principal types")
</span><span class="cx"> print(" --list-principals type: list all principals of the given type")
</span><span class="cx"> print(" --list-read-proxies: list proxies with read-only access")
</span><span class="lines">@@ -129,7 +130,8 @@
</span><span class="cx"> "config=",
</span><span class="cx"> "add=",
</span><span class="cx"> "remove",
</span><del>- "search=",
</del><ins>+ "context=",
+ "search",
</ins><span class="cx"> "list-principal-types",
</span><span class="cx"> "list-principals=",
</span><span class="cx">
</span><span class="lines">@@ -175,7 +177,8 @@
</span><span class="cx"> addType = None
</span><span class="cx"> listPrincipalTypes = False
</span><span class="cx"> listPrincipals = None
</span><del>- searchPrincipals = None
</del><ins>+ searchContext = None
+ searchTokens = None
</ins><span class="cx"> printGroupInfo = False
</span><span class="cx"> scheduleGroupRefresh = False
</span><span class="cx"> principalActions = []
</span><span class="lines">@@ -207,8 +210,11 @@
</span><span class="cx"> elif opt in ("", "--list-principals"):
</span><span class="cx"> listPrincipals = arg
</span><span class="cx">
</span><ins>+ elif opt in ("", "--context"):
+ searchContext = arg
+
</ins><span class="cx"> elif opt in ("", "--search"):
</span><del>- searchPrincipals = arg
</del><ins>+ searchTokens = args
</ins><span class="cx">
</span><span class="cx"> elif opt in ("", "--list-read-proxies"):
</span><span class="cx"> principalActions.append((action_listProxies, "read"))
</span><span class="lines">@@ -356,9 +362,10 @@
</span><span class="cx"> function = runListPrincipals
</span><span class="cx"> params = (listPrincipals,)
</span><span class="cx">
</span><del>- elif searchPrincipals:
</del><ins>+ elif searchTokens:
</ins><span class="cx"> function = runSearch
</span><del>- params = (searchPrincipals,)
</del><ins>+ searchTokens = [t.decode("utf-8") for t in searchTokens]
+ params = (searchTokens, searchContext)
</ins><span class="cx">
</span><span class="cx"> else:
</span><span class="cx"> if not args:
</span><span class="lines">@@ -420,13 +427,16 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><del>-def runSearch(service, store, searchTerm):
</del><ins>+def runSearch(service, store, tokens, context=None):
</ins><span class="cx"> directory = store.directoryService()
</span><del>- fields = []
- for fieldName in ("fullNames", "emailAddresses"):
- fields.append((fieldName, searchTerm, True, "contains"))
</del><span class="cx">
</span><del>- records = list((yield directory.recordsMatchingTokens(searchTerm.strip().split())))
</del><ins>+ records = list(
+ (
+ yield directory.recordsMatchingTokens(
+ tokens, context=context
+ )
+ )
+ )
</ins><span class="cx"> if records:
</span><span class="cx"> records.sort(key=operator.attrgetter('fullNames'))
</span><span class="cx"> print("{n} matches found:".format(n=len(records)))
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolstestprincipalsusersgroupsxml"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/test/principals/users-groups.xml (14121 => 14122)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/test/principals/users-groups.xml        2014-10-29 16:57:26 UTC (rev 14121)
+++ CalendarServer/trunk/calendarserver/tools/test/principals/users-groups.xml        2014-10-29 20:28:29 UTC (rev 14122)
</span><span class="lines">@@ -99,6 +99,14 @@
</span><span class="cx"> <email>user10@example.com</email>
</span><span class="cx"> </record>
</span><span class="cx">
</span><ins>+ <record type="user">
+ <short-name>testuser1</short-name>
+ <uid>testuser1</uid>
+ <password>testuser1</password>
+ <full-name>Test User One</full-name>
+ <email>testuser10@example.com</email>
+ </record>
+
</ins><span class="cx"> <record type="group">
</span><span class="cx"> <uid>e5a6142c-4189-4e9e-90b0-9cd0268b314b</uid>
</span><span class="cx"> <short-name>testgroup1</short-name>
</span><span class="lines">@@ -106,6 +114,20 @@
</span><span class="cx"> <member-uid type="users">user01</member-uid>
</span><span class="cx"> <member-uid type="users">user02</member-uid>
</span><span class="cx"> </record>
</span><ins>+
+ <record type="group">
+ <uid>group2</uid>
+ <short-name>group2</short-name>
+ <full-name>Test Group Two</full-name>
+ </record>
+
+ <record type="group">
+ <uid>group3</uid>
+ <short-name>group3</short-name>
+ <full-name>Test Group Three</full-name>
+ </record>
+
+
</ins><span class="cx"> <!--
</span><span class="cx"> <user repeat="10">
</span><span class="cx"> <uid>user%02d</uid>
</span></span></pre></div>
<a id="CalendarServertrunkcalendarservertoolstesttest_principalspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/test/test_principals.py (14121 => 14122)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/test/test_principals.py        2014-10-29 16:57:26 UTC (rev 14121)
+++ CalendarServer/trunk/calendarserver/tools/test/test_principals.py        2014-10-29 20:28:29 UTC (rev 14122)
</span><span class="lines">@@ -35,9 +35,6 @@
</span><span class="cx"> def setUp(self):
</span><span class="cx"> super(ManagePrincipalsTestCase, self).setUp()
</span><span class="cx">
</span><del>- # # Since this test operates on proxy db, we need to assign the service:
- # calendaruserproxy.ProxyDBService = calendaruserproxy.ProxySqliteDB(os.path.abspath(self.mktemp()))
-
</del><span class="cx"> testRoot = os.path.join(os.path.dirname(__file__), "principals")
</span><span class="cx"> templateName = os.path.join(testRoot, "caldavd.plist")
</span><span class="cx"> templateFile = open(templateName)
</span><span class="lines">@@ -138,12 +135,26 @@
</span><span class="cx">
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_search(self):
</span><del>- results = yield self.runCommand("--search=user")
- self.assertTrue("10 matches found" in results)
</del><ins>+ results = yield self.runCommand("--search", "user")
+ self.assertTrue("11 matches found" in results)
</ins><span class="cx"> for i in xrange(1, 10):
</span><span class="cx"> self.assertTrue("user%02d" % (i,) in results)
</span><span class="cx">
</span><ins>+ results = yield self.runCommand("--search", "user", "04")
+ self.assertTrue("1 matches found" in results)
+ self.assertTrue("user04" in results)
</ins><span class="cx">
</span><ins>+ results = yield self.runCommand("--context=group", "--search", "test")
+ self.assertTrue("2 matches found" in results)
+ self.assertTrue("group2" in results)
+ self.assertTrue("group3" in results)
+
+ results = yield self.runCommand("--context=attendee", "--search", "test")
+ self.assertTrue("3 matches found" in results)
+ self.assertTrue("testuser1" in results)
+ self.assertTrue("group2" in results)
+ self.assertTrue("group3" in results)
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def test_addRemove(self):
</span><span class="cx"> results = yield self.runCommand(
</span></span></pre></div>
<a id="CalendarServertrunktxdavwhogroupspy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/txdav/who/groups.py (14121 => 14122)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/txdav/who/groups.py        2014-10-29 16:57:26 UTC (rev 14121)
+++ CalendarServer/trunk/txdav/who/groups.py        2014-10-29 20:28:29 UTC (rev 14122)
</span><span class="lines">@@ -446,7 +446,7 @@
</span><span class="cx"> )
</span><span class="cx">
</span><span class="cx"> if membershipChanged:
</span><del>- self.log.debug(
</del><ins>+ self.log.info(
</ins><span class="cx"> "Membership changed for group {uid} {name}",
</span><span class="cx"> uid=groupUID,
</span><span class="cx"> name=cachedName
</span></span></pre>
</div>
</div>
</body>
</html>