Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add more directory proxy commands

  • Loading branch information
m0rgen committed Feb 4, 2014
1 parent 4bcd4af commit 6608e8190054da7e194de5386622b9daf85e1689
Showing with 36 additions and 3 deletions.
  1. +2 −0 txdav/dps/client.py
  2. +18 −2 txdav/dps/protocol.py
  3. +16 −1 txdav/dps/service.py
@@ -34,6 +34,8 @@ def makeEvenBetterRequest():
print("guid: {r}".format(r=record))
records = (yield ds.recordsWithRecordType(RecordType.user))
print("recordType: {r}".format(r=records))
records = (yield ds.recordsWithEmailAddress("cdaboo@bitbucket.calendarserver.org"))
print("emailAddress: {r}".format(r=records))


def succeeded(result):
@@ -119,7 +119,7 @@ def recordToDict(self, record):
@RecordWithShortNameCommand.responder
@inlineCallbacks
def recordWithShortName(self, recordType, shortName):
recordType = recordType.decode("utf-8")
recordType = recordType # keep as bytes
shortName = shortName.decode("utf-8")
log.debug("RecordWithShortName: {r} {n}", r=recordType, n=shortName)
record = (yield self._directory.recordWithShortName(
@@ -164,7 +164,7 @@ def recordWithGUID(self, guid):
@RecordsWithRecordTypeCommand.responder
@inlineCallbacks
def recordsWithRecordType(self, recordType):
recordType = recordType.decode("utf-8")
recordType = recordType # as bytes
log.debug("RecordsWithRecordType: {r}", r=recordType)
records = (yield self._directory.recordsWithRecordType(
RecordType.lookupByName(recordType))
@@ -177,3 +177,19 @@ def recordsWithRecordType(self, recordType):
}
log.debug("Responding with: {response}", response=response)
returnValue(response)


@RecordsWithEmailAddressCommand.responder
@inlineCallbacks
def recordsWithEmailAddress(self, emailAddress):
emailAddress = emailAddress.decode("utf-8")
log.debug("RecordsWithEmailAddress: {e}", e=emailAddress)
records = (yield self._directory.recordsWithEmailAddress(emailAddress))
fieldsList = []
for record in records:
fieldsList.append(self.recordToDict(record))
response = {
"fieldsList": pickle.dumps(fieldsList),
}
log.debug("Responding with: {response}", response=response)
returnValue(response)
@@ -37,7 +37,8 @@

from .protocol import (
DirectoryProxyAMPProtocol, RecordWithShortNameCommand, RecordWithUIDCommand,
RecordWithGUIDCommand, RecordsWithRecordTypeCommand
RecordWithGUIDCommand, RecordsWithRecordTypeCommand,
RecordsWithEmailAddressCommand
)

from twisted.internet import reactor
@@ -160,6 +161,20 @@ def _call(ampProto):
return d


def recordsWithEmailAddress(self, emailAddress):

def _call(ampProto):
return ampProto.callRemote(
RecordsWithEmailAddressCommand,
emailAddress=emailAddress
)

d = self._getConnection()
d.addCallback(_call)
d.addCallback(self._processMultipleRecords)
return d


class DirectoryRecord(BaseDirectoryRecord):
pass

0 comments on commit 6608e81

Please sign in to comment.
You can’t perform that action at this time.