[CalendarServer-changes] [12514] CalendarServer/trunk/txdav/dps

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 12:25:25 PDT 2014


Revision: 12514
          http://trac.calendarserver.org//changeset/12514
Author:   sagen at apple.com
Date:     2014-01-31 13:37:41 -0800 (Fri, 31 Jan 2014)
Log Message:
-----------
Trying to serialize records across amp

Modified Paths:
--------------
    CalendarServer/trunk/txdav/dps/client.py
    CalendarServer/trunk/txdav/dps/protocol.py
    CalendarServer/trunk/txdav/dps/service.py

Modified: CalendarServer/trunk/txdav/dps/client.py
===================================================================
--- CalendarServer/trunk/txdav/dps/client.py	2014-01-31 21:27:07 UTC (rev 12513)
+++ CalendarServer/trunk/txdav/dps/client.py	2014-01-31 21:37:41 UTC (rev 12514)
@@ -14,28 +14,25 @@
 # limitations under the License.
 ##
 
+from txdav.dps.service import DirectoryService
 from twext.who.idirectory import RecordType
 from twext.python.log import Logger
 from twisted.internet import reactor
-import cPickle as pickle
 import sys
 
 log = Logger()
 
-print sys.path
-from txdav.dps.service import DirectoryService
 
 
 def makeBetterRequest():
 
     shortName = sys.argv[1]
 
-    ds = DirectoryService()
+    ds = DirectoryService(None)
     d = ds.recordWithShortName(RecordType.user, shortName)
 
-    def gotResults(result):
-        result = pickle.loads(result)
-        print('Done: %s' % (result,))
+    def gotResults(record):
+        print('Done: %s' % (record,))
         reactor.stop()
     d.addCallback(gotResults)
     reactor.run()

Modified: CalendarServer/trunk/txdav/dps/protocol.py
===================================================================
--- CalendarServer/trunk/txdav/dps/protocol.py	2014-01-31 21:27:07 UTC (rev 12513)
+++ CalendarServer/trunk/txdav/dps/protocol.py	2014-01-31 21:37:41 UTC (rev 12514)
@@ -18,6 +18,7 @@
 from twisted.protocols import amp
 from twisted.internet.defer import inlineCallbacks, returnValue
 from twext.python.log import Logger
+import cPickle as pickle
 
 log = Logger()
 
@@ -29,9 +30,7 @@
         ('shortName', amp.String()),
     ]
     response = [
-        ('fullNames', amp.ListOf(amp.String())),
-        ('shortNames', amp.ListOf(amp.String())),
-        ('emailAddresses', amp.ListOf(amp.String())),
+        ('record', amp.String()),
     ]
 
 
@@ -54,10 +53,9 @@
         record = (yield self._directory.recordWithShortName(
             RecordType.lookupByName(recordType), shortName)
         )
+        record.service = None
         response = {
-            "fullNames": [i.encode("utf-8") for i in record.fullNames],
-            "shortNames": [i.encode("utf-8") for i in record.shortNames],
-            "emailAddresses": [i.encode("utf-8") for i in record.emailAddresses],
+            "record": pickle.dumps(record),
         }
         log.debug("Responding with: {response}", response=response)
         returnValue(response)

Modified: CalendarServer/trunk/txdav/dps/service.py
===================================================================
--- CalendarServer/trunk/txdav/dps/service.py	2014-01-31 21:27:07 UTC (rev 12513)
+++ CalendarServer/trunk/txdav/dps/service.py	2014-01-31 21:37:41 UTC (rev 12514)
@@ -40,13 +40,14 @@
 class DirectoryService(BaseDirectoryService):
 
     def _getConnection(self):
-        path = config.DirectoryProxy.SocketPath
-        return ClientCreator(reactor, amp.AMP).connectUnix(path)
+        # path = config.DirectoryProxy.SocketPath
+        path = "data/Logs/state/directory-proxy.sock"
+        return ClientCreator(reactor, amp.AMP).connectUNIX(path)
 
     def recordWithShortName(self, recordType, shortName):
 
-        def serialize(result):
-            return pickle.dumps(result)
+        def deserialize(result):
+            return pickle.loads(result['record'])
 
         def call(ampProto):
             return ampProto.callRemote(
@@ -55,7 +56,7 @@
                 shortName=shortName.encode("utf-8")
             )
 
-        return self._getConnection().addCallback(call).addCallback(serialize)
+        return self._getConnection().addCallback(call).addCallback(deserialize)
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/39b07fef/attachment.html>


More information about the calendarserver-changes mailing list