This is a request, not a promise (or threat) that I'm going to change
things. Your input is very much desired.
RFC 5789[1] codifies the HTTP PATCH method as a feature for doing
partial updates to resources. It was originally part of the HTTP 1.1
discussions but didn't make it in because the participants didn't
reach agreement. It's now standards track, but not widely used.
In current TiddlyWeb, resource udpates are _never_ partial. When you
PUT a recipe, bag or tiddler a complete representation of the entity
is sent in the body of the request, replacing the server-side instance.
For the most part this works well:
* It is fairly unambiguous.
* It is nicely aligned with the origial planned content types of tiny
tiddlers.
* It is well integrated with the serialization architecture used in
TiddlyWeb.
PATCH is gaining acceptance and it may now make sense to support it in
some form in TiddlyWeb because:
* It keeps TiddlyWeb aligned with norms.
* Some content (such as binary tiddlers[2]) is not small and doing
partial updates could be more efficient.
A possible scenario is that a User-Agent PUTs a large tiddler, say a
movie, in raw binary form. A followup PATCH sets some tags on that
that tiddler (some header elided):
PATCH /bags/foo/tiddlers/bigtidder
Content-Type: application/json
If-Match: <some etag>
{"tags": ["movie", "****"]}
This changes (patches) the existing "bigtiddler" so it now has tags
"movie" and "****", but the raw binary content (stored as the text
attribute) remains the same.
Using PATCH instead of PUT or POST here is good because there's no
additional distinguishing that needs to be done in the request to know
that the request is a PATCH.
There are several concerns with this that would need to be resolved
before an implementation could be made:
* JSON makes a pretty easy patch content type. Would there need to be
others? Is it in the spirit of TiddlyWeb to only support one?
* In the above example are we setting tags in an absolute sense? Adding
tags? If adding, how do we remove? If adding, is it maybe better to
have tags as a separate (sub-) resource? Are tags special or are all
attributes candidates for sub-resourcing?[3]
* The TiddlyWeb serialization architecture is not set up to handle
partial representations of resources. It would be easier to handle
PATCH outside the serialization stack. This would make things like
doing just JSON easier, but things could get mighty complicated is
other partial representations are to be considered.
* Do bag and recipe entities need partial representations. It might
make sense for policy updates, but the question of add or remove
(as with tags) gets confused again.[3]
It's probably hard for many of the readers to believe this, but
TiddlyWeb strives to limit ambiguity, so my main concern with using
PATCH is that it might introduce some, or even a lot, and it would be
good to avoid that if the benefits are not large.
In a TiddlyWiki context partial updates are probably not a huge win.
Some requests could be completed more quickly, but semantically
TiddlyWiki and the adaptor mechanism work on whole representations,
because they are always there.
As TiddlySpace broadens the opportunities for tiddlers in strange new
worlds, PATCH might be useful.
What do you think?
Thanks.
[1]
http://tools.ietf.org/html/rfc5789
[2]
https://groups.google.com/d/topic/tiddlyweb/AMOo0GeLwHk/discussion
[3] My thinking on this aspect of things is that a PATCH of a tiddler
would operate on the tiddler as if it is a set of key:value pairs and
with PATCH you can set the value of one or more keys. So if a tiddler
already has tags "foo" and "bar", to add "boom" a patch would look
like this:
{"tags": ["foo", "bar", "boom"]}
Removing foo would look like this:
{"tags": ["bar", "boom"]}
This is not super elegant and expressive, but it is simple to
understand and simple to implement.
With bag and recipe policies, the advantage of a PATCH is fairly
limited if a patch resets the value of an entire key, because the use
case I can most think of is "add user X to policy constraint Y".
--
Chris Dent
http://burningchrome.com/
[...]