← Back to team overview

zeitgeist team mailing list archive

[Bug 691167] Re: The payload is sometimes mentioned as string and sometimes as array of bytes

 

Markus,
I got this when trying to work on the new blacklist API.

So you need to run the daemon from this branch.
lp:~manishsinha/zeitgeist/reproduce-691167

and then need to run the following commands on the python console
>>> sub = Subject.new_for_values()
>> ev = Event.new_for_values(actor="application://foo.desktop", subjects=[sub,])
>>> obj=dbus.SessionBus().get_object("org.gnome.zeitgeist.Engine","/org/gnome/zeitgeist/blacklist")
>>> iface=dbus.Interface(obj, "org.gnome.zeitgeist.Blacklist")
>>> blk= map(Event.new_for_struct,iface.GetBlacklist())
>>> blk.append(ev)
>>> iface.SetBlacklist(blk, "foo")

Then go and check the console.  You would get the output like

Event([dbus.Array([u'', u'1292500628312', u'', u'', u'application://foo.desktop'], signature=dbus.Signature('s')), [Subject([u'', u'', u'', u'', u'', u'', u''])], dbus.Array([], signature=dbus.Signature('y'))])
{'foo': [[[u'', u'1292500628312', u'', u'', u'application://foo.desktop'], [[u'', u'', u'', u'', u'', u'', u'']], "dbus.Array([], signature=dbus.Signature('y'))"]]}
[2010-12-16 21:32:44,249] - DEBUG - zeitgeist.blacklist - Blacklist updated: {'foo':
 [[[u'', u'1292500628312', u'', u'', u'application://foo.desktop'], [[u'', u'', u'', u'', u'', u'', u'']], "dbus.Array([], signature=dbus.Signature('y'))"]]}

** Branch linked: lp:~manishsinha/zeitgeist/reproduce-691167

-- 
You received this bug notification because you are a member of Zeitgeist
Framework Team, which is subscribed to Zeitgeist Framework.
https://bugs.launchpad.net/bugs/691167

Title:
  The payload is sometimes mentioned as string and sometimes as array of bytes

Status in Zeitgeist Framework:
  New

Bug description:
  In the event serialization format, the third array is array of bytes or ay as dbus signature.

When an event enters an extension, it looks like
Event([dbus.Array([u'', u'1292500628312', u'', u'', u'application://foo.desktop'], signature=dbus.Signature('s')), [Subject([u'', u'', u'', u'', u'', u'', u''])], dbus.Array([], signature=dbus.Signature('y'))])

which implies that payload is array of bytes

Now look at _zeitgeist/engine/datamodel.py at line 58
where you get the line
>> popo.append(str(ev[2]))

Really so when you do str() on dbus.Array([], signature=dbus.Signature('y'))
you get "dbus.Array([], signature=dbus.Signature('y'))" instead of the contents of bytes converted to string


Now when you call Event.get_plain on 

Event([dbus.Array([u'', u'1292500628312', u'', u'', u'application://foo.desktop'], signature=dbus.Signature('s')), [Subject([u'', u'', u'', u'', u'', u'', u''])], dbus.Array([], signature=dbus.Signature('y'))])

you get

[[u'', u'1292500628312', u'', u'', u'application://foo.desktop'], [[u'', u'', u'', u'', u'', u'', u'']], "dbus.Array([], signature=dbus.Signature('y'))"]

Now what you expect





References