midgard-paths 1.0beta

Abstract

A path is a 1-1 reference to a midgard object. It specifies a location in the tree and a “label” of the object which is unique in that context. So contrary to the guid, the path of an object changes when it is renamed or moved around.

Syntax

/class1:object1/class2:object2/class3:object3/...

where object1 of class1 is the parent of object2 of class2, and so on.

All objects are contained within a sitegroup, so in a complete path, there is always a sitegroup at the beginning. This can be omitted for objects of the current sitegroup.

If the object is of the same class as the parent, the class can be omitted. Example:

/topic:myTopic/article:someArticle/article:myReplyArticle/attachment:image.jpg

could be written as:

/topic:myTopic/article:someArticle/myReplyArticle/attachment:image.jpg

class names can be abbreviated for faster typing, see table below.

Hierarchy

This is the detailed containment hierarchy, by class:

Object of class (abbreviation)

can be child of

is identified by

article (ar)

topic, article

name

attachment (at)

any object

name

element (el)

style

name

event (ev)

sitegroup, event

guid (name not unique)

eventmember (em)

event

guid (rest not unique)

group (gr)

sitegroup, group

name

host (ho)

sitegroup

label1

member (me)

person

guid

page (pa)

sittegroup, page

name

pageelement (pe)

page

name

person (pr)

sitegroup

name

snippet (sn)

snippetdir

name

snippetdir (sd)

sitegroup, snippetdir

name

sitegroup (sg)

(always root)

name

style (st)

sitegroup, style

name

topic (to)

sitegroup, topic

name


New snippet

/midgard-paths/paths

New functions

mgd_get_object_by_path($path)

$path: the path of the object

returns the object, a midgard error code on failure.

mgd_get_path($obj)

$obj: can be midgard object as created by mgd_get_xxx or a guid

returns the complete path of the object, MGD_ERR_NOT_EXISTS if the object does not exist.



1special construct to identify a host uniquely: name:port|prefix ex: www.example.org:80|example