[Fwd: add leading _ to each reserved attribute name; _size is reserved, too]

Jim Meyering jim at meyering.net
Sat Nov 6 07:08:15 UTC 2010


Jeff Darcy wrote:
> On Fri, 2010-11-05 at 21:48 +0100, Jim Meyering wrote:
>> Jeff Darcy wrote:
>> > ACK, except that I don't entirely agree with changing "bucket" to
>> > "_bucket" in the XML/JSON output.  Unlike bucket/object/attribute names
>> > which can be specified on the input side, "rel" strings are output-only.
>> > REST religion says that those are supposed to be visible and fixed parts
>> > of the API, hence as programmer-friendly as possible, and since adding
>> > underscores in that particular context doesn't actually change any
>> > semantics it should probably be avoided.
>>
>> If we avoid the underscore there, there is nothing to distinguish the
>> reserved "_bucket" from the non-reserved "bucket" in xml or json output.
>> Isn't that a problem?
>
> I don't think it is.  The user can only specify bucket/object/attribute
> names as parts of a URI; "rel" strings are in a completely separate
> namespace.  Since they're basically types, not values, the only
> restriction that would make sense would be which we *accept* - not which
> we forbid.  We don't happen to have any calls that accept structured
> (e.g. JSON/XML) input, so even that's unnecessary in our case.  It
> doesn't matter that "bucket" as a type ID is not among the strings
> reserved as object/attribute names, because they're conceptually
> separate things.

Oh, I see now.  Thanks.
With this incremental reverting three of the changes,
I think it does what we want:

diff --git a/rest.c b/rest.c
index fada136..96b8348 100644
--- a/rest.c
+++ b/rest.c
@@ -998,7 +998,7 @@ root_blob_generator (void *ctx, uint64_t pos, char *buf, int max)
 	}

 	if (meta_query_next(ms->query,&bucket,&key)) {
-		len = tmpl_root_entry(ms->gen_ctx,"_bucket",bucket);
+		len = tmpl_root_entry(ms->gen_ctx,"bucket",bucket);
 		if (!len) {
 			return -1;
 		}
diff --git a/t/basic b/t/basic
index 71821f8..3d610d9 100644
--- a/t/basic
+++ b/t/basic
@@ -31,7 +31,7 @@ cat <<EOF > root.xml || framework_failure_
 <api service="image_warehouse" version="$VERSION">
 	<link rel="bucket_factory" href="http://localhost:$port/_new"/>
 	<link rel="provider_list" href="http://localhost:$port/_providers"/>
-	<link rel="_bucket" href="$bucket"/>
+	<link rel="bucket" href="$bucket"/>
 </api>
 EOF

@@ -49,7 +49,7 @@ cat <<EOF > root.json || framework_failure_
 			"link": "http://localhost:$port/_providers"
 		},
 		{
-			"rel": "_bucket",
+			"rel": "bucket",
 			"link": "$bucket"
 		}
 	]


More information about the iwhd-devel mailing list