Object Path Naming Conventions

Simon McVittie simon.mcvittie at collabora.co.uk
Wed Jan 16 01:55:00 PST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Wed, 16 Jan 2008 at 10:26:06 +0200, S.Çağlar Onur wrote:
> So could you please tell why this restriction exists, i cannot find any 
> related discussion on mailing list archives and spec. says nothing more? 

Why it exists is by now pretty irrelevant - it's important for
interoperability that all D-Bus implementations agree on what is a valid
object path, so the definition of object-path is fixed from now until
the next incompatible protocol change (ideally, that means forever).

(I wasn't around when D-Bus was designed, but the character set
restrictions for object paths, bus names etc. all resemble the allowed
characters in C identifiers; I assume this was to make it easier to map
them into identifiers in C and similar languages. The only two sane
choices would seem to be "heavily restricted" (like C identifiers) and
"completely arbitrary" (like Unix filenames), and the designers of D-Bus
chose the "heavily restricted" option.

I suggest using some suitable reversible escaping mechanism; if your
package names are almost, but not quite, valid object path components,
you could copy tp_escape_as_identifier() from telepathy-glib (it's
basically URI escaping, with _ instead of % and a smaller allowed
character set, and it produces names which are valid object path
components, bus name components and C identifiers).

Latest version of tp_escape_as_identifer(): search for it in
http://darcs.collabora.co.uk/darcsweb.cgi?r=telepathy/telepathy-glib;a=headblob;f=/telepathy-glib/util.c,
or check out http://darcs.collabora.co.uk/darcs/telepathy/telepathy-glib
with Darcs and look in telepathy-glib/util.c.

There is no tp_unescape_identifier() (we've never needed it - we only
use a reversible algorithm to guarantee that distinct strings
will produce distinct object paths) but it would be entirely possible to
implement it.

There's a Python implementation of the same algorithm in the OLPC's
Presence Service
(http://dev.laptop.org/git?p=projects/presence-service;a=blob;f=src/psutils.py;hb=HEAD,
search for escape_identifier).

    Simon
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHjdR0WSc8zVUw7HYRAlUOAKDiZZfFnD8s6OTRv069lbxRQBECYwCgwHYr
TRoQUc+uSkd7RDo72vCgIjo=
=c+Dm
-----END PGP SIGNATURE-----


More information about the dbus mailing list