Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURIE maybe not working? #7

Open
mortbauer opened this issue Aug 24, 2013 · 3 comments
Open

CURIE maybe not working? #7

mortbauer opened this issue Aug 24, 2013 · 3 comments

Comments

@mortbauer
Copy link

I have the impression, that CURIE does actually not work, they only expand to the correct url if you have a "base_uri" specified which prefixes everything.

@wharris
Copy link
Owner

wharris commented Aug 29, 2013

Can you give an example of CURIE expansion not working. It seems to work for me.

Here, a document is being loaded without any base_uri:

import dougrain
obj = {"_links": {"curies": [{'name': "app",
                              'href': "/rels/{rel}",
                              'templated': True}],
                  "self": {'href': "/1"},
                  "app:home": {'href': "/"},
                  "app:spam": {'href': "/main"},
                  "app:eggs": {'href': "/eggs/1"},
                  "/rels/eggs": {'href': "/eggs/2"}}}
doc = dougrain.Document.from_object(obj)
assert doc.links["/rels/spam"].url() == "/main"
assert doc.links["app:spam"].url() == "/main"
assert len(doc.links["app:eggs"]) == 2
assert doc.links["app:eggs"] == doc.links["/rels/eggs"]

@mortbauer
Copy link
Author

If that is how it should work, then I just didn't get what a CURIE should do. I thought that:

doc.links["app:spam"].url() 

should expand to

"/rels/main"

I'm sorry for taking your time, probably should have studied the CURIE's better.

@wharris
Copy link
Owner

wharris commented Aug 30, 2013

You can expand a CURIE from a document using the expand_curie method. In the example above, doc.expand_curie("app:spam") would return "/rels/spam".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants