Repository navigation
API Changes
Pre-release
Pre-release
-
Attributes have been renamed to properties.
-
The template token for CURIEs is now
{rel}, rather than{relation}. -
Improved API for
Document().add_link. The second argument can now be a
URI string or aDocumentobject as well as aLinkobject. Additional
keyword arguments are added to the link's properties. -
DocumentandLinkobjects are now iterable, yeilding themselves
exactly once, so single and multiple links for a relation can be treated the
same with a for loop.Example:
>>> import dougrain >>> doc = dougrain.Document.empty("http://localhost/") >>> doc.add_link('child', "/1") >>> doc.links['child'] <Link 'http://localhost/1'> >>> [link.href for link in doc.links['child']] ['/1'] >>> doc.add_link('child', "/2") >>> doc.links['child'] [<Link 'http://localhost/1'>, <Link 'http://localhost/2'>] >>> [link.href for link in doc.links['child']] ['/1', '/2']
-
Documentnow treats link relationship types as equal if they are
equivalent to the same URI when expanded.Example:
>>> import dougrain >>> doc = dougrain.Document.empty("http://localhost/") >>> doc.set_curie('role', "/roles/{rel}") >>> doc.add_link("role:app", "/apps/1") >>> doc.add_link("/roles/app", "/apps/2") >>> doc.add_link("http://localhost/roles/app", "/apps/3") >>> [link.href for link in doc.links["role:app"]] ['/apps/1', '/apps/2', '/apps/3'] >>> [link.href for link in doc.links["/roles/app"]] ['/apps/1', '/apps/2', '/apps/3'] >>> [link.href for link in doc.links["http://localhost/roles/app"]] ['/apps/1', '/apps/2', '/apps/3']