wharris / dougrain Goto Github PK
View Code? Open in Web Editor NEWPython library for working with JSON HAL
License: MIT License
Python library for working with JSON HAL
License: MIT License
Wondering if you've considered using collections.OrderedDict
to make key order somewhat predictable.
JSON Hypertext Application Language Internet Draft 4 has been published but Dougrain is still stuck on Draft 3.
Draft 4: http://tools.ietf.org/html/draft-kelly-json-hal-04
Diffs between Draft 3 and Draft 4: http://tools.ietf.org/rfcdiff?url2=draft-kelly-json-hal-04.txt
I don't think the spec has a rule for this, but I could easily be wrong on this. Currently, when using Document.embed
, you get a different data structure depending on whether you call it once or more often. If you iterate over, for example, a database result and want to provide a unified interface independent of the result length, you would have to have make a check like this on the server:
if len(result) == 1:
doc.embed('rel', [result])
else:
[doc.embed('rel', r) for r in result]
I'd like to have a flag on embed
to always wrap the object in a list, even on the first call. What do you think?
Dougrain does not support draft 5 of the HAL spec.
The main change in draft 5 is to make explicit the Hypertext Cache Pattern, embedded resources are merely advice to the client and should not replace links.
Servers SHOULD NOT entirely "swap out" a link for an embedded
resource (or vice versa) because client support for this technique is
OPTIONAL.
Dougrain should ensure that an equivalent link exists whenever a resource is embedded in a document.
Draft 5: http://tools.ietf.org/html/draft-kelly-json-hal-05
Diffs between draft 4 and draft 5: http://tools.ietf.org/rfcdiff?url2=draft-kelly-json-hal-05.txt
_links
often contain URI templates[http://tools.ietf.org/html/rfc6570],
This is what I do at the moment:
the_url = uritemplate.expand( mydoc.links['myrel'].url(), { "a": b, "c": d, })
I'd like to have this functionality built into dougrain, so I can write
the_url = mydoc.links['myrel'].url(a=b, c=d)
Also, I'd have to re-read the HAL spec to figure out if there are situations where the values can be extrapolated from the document itself, so the url could expand automatically.
https://pypi.python.org/pypi/uritemplate is a great URI template library I've worked with.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.