← Back to team overview

zeitgeist team mailing list archive

[Merge] lp:~seif/zeitgeist/fixing-payloads into lp:zeitgeist

 

Seif Lotfy has proposed merging lp:~seif/zeitgeist/fixing-payloads into lp:zeitgeist.

Requested reviews:
  Zeitgeist Framework Team (zeitgeist)
Related bugs:
  #692645 sending payload from engine to client does not work
  https://bugs.launchpad.net/bugs/692645


This branch fixes
https://bugs.launchpad.net/zeitgeist/+bug/692645
by mapping the bytes in the payload to ord before sending it out to the client
-- 
https://code.launchpad.net/~seif/zeitgeist/fixing-payloads/+merge/44248
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~seif/zeitgeist/fixing-payloads into lp:zeitgeist.
=== modified file '_zeitgeist/engine/datamodel.py'
--- _zeitgeist/engine/datamodel.py	2010-01-23 19:20:41 +0000
+++ _zeitgeist/engine/datamodel.py	2010-12-20 17:32:43 +0000
@@ -44,8 +44,11 @@
 				subject[n] = self._to_unicode(value)
 		# The payload require special handling, since it is binary data
 		# If there is indeed data here, we must not unicode encode it!
-		if self[2] is None: self[2] = u""
-	
+		if self[2] is None:
+			self[2] = u""
+		else:
+			self[2] = map(ord, self[2])
+			
 	@staticmethod
 	def get_plain(ev):
 		"""

=== modified file 'test/remote-test.py'
--- test/remote-test.py	2010-09-22 18:44:16 +0000
+++ test/remote-test.py	2010-12-20 17:32:43 +0000
@@ -321,6 +321,19 @@
 		registry = iface.get_extension("DataSourceRegistry", "data_source_registry")
 		registry.GetDataSources()
 		
+	def testFindEventsWithPayload(self):
+		mainloop = gobject.MainLoop()
+		payload = "Hello World"
+		def callback(ids):
+			def callback2(events):
+				mainloop.quit()
+				self.assertEquals(events[0].payload, payload)
+			self.client.get_events(ids, callback2)
+		events = [Event.new_for_values(actor=u"boo", timestamp=124, subject_uri="file://yomomma")]
+		events[0].payload = payload
+		self.client.insert_events(events, callback)
+		mainloop.run()
+		
 class ZeitgeistRemoteInterfaceTest(unittest.TestCase):
 	
 	def setUp(self):