I’ve just pushed a new version of fdb.py to the GitHub repository.
The main change in this version is that I’ve added support for allowing the user to choose whether to use what we might call Unix-style paths or Fluidinfo-style paths.
Until now, fdb.py has, as part of its shell-like functionality, deliberately provided an alternative view of Fluidinfo from the underlying structure. The main features of this “Unix-style view” are as follows:
- Full (absolute) fdb.py tag paths start with a leading slash. So my rating tag would be /njr/rating rather than njr/rating.
- A tag path without a slash is taken to be a relative path, currently always relative to the user’s namespace (though there are alternate versions where there is a notion of a current working namespace (CWD) which can be changed with a cd command). Thus, when using my credentials, the Fluidinfo tag njr/rating can be referred to as rating while ntolls rating is ntoll/rating.
- /about is provided as a synonym for the special tag fluiddb/about (the about tag).
- /id is provided as a pseudo-tag that will report the value of the object’s Fluidinfo ID.
This was not carried all the way: I didn’t re-write queries, but, for me at least, it saved much typing and pain when using fdb from the command line.
This release (1.33) maintains this behaviour by default, but allows the user to configure or tell the system that she would prefer to use genuine, regular all-American Fluidinfo-style paths. There are two ways to invoke this alternative behaviour:
If you would always prefer to user regular Fluidinfo-style paths, the best thing to do is to add a third line to the credentials file that fdb uses saying
unix-style-paths false(I need hardly add that using true instead of false sets the opposite preference.)
Alternatively, if you just want to override the configured or default behaviour for a one-off command, use the command-line flags -F. Similarly, to override the behaviour to force Unix-style paths, use -U.
When you choose Fluidinfo-style-paths, this is what happens:
- Only command-line commands are affected: if you use fdb.py through the API, nothing changes unless you work quite hard.
- Any time you specify a path, it needs to be an absolute path. In Terry’s world, absolutely all paths are absolute.
- /about is not accepted as a synonym for fluiddb/about
- The only special case is /id. Since this is a useful pseudo tag (in my view), and since it has no namespace, the same trick works as when using unix-style paths. Thus you can request the tag /id and it will return the object ID.
- Output as well as input is affected, i.e. tag paths will be reported without a leading slash.
Examples¶
Old (default) behaviour:
$ fdb tags -a "Eiffel Tower"
Object with about="Eiffel Tower":
/objects/93bd1999-0998-49cc-8004-af457ce34ce4
/njr/location = "Paris"
/fluiddb/about = "Eiffel Tower"
/njr/index/about
Behaviour with -F or with unix-style-paths false
$ fdb tags -F -a "Eiffel Tower"
Object with about="Eiffel Tower":
/objects/93bd1999-0998-49cc-8004-af457ce34ce4
njr/location = "Paris"
fluiddb/about = "Eiffel Tower"
njr/index/about
Setting and showing tags (old/default behaviour):
$ fdb tag -a "Eiffel Tower" rating=7
$ fdb show -a "Eiffel Tower" rating
Object with about="Eiffel Tower":
/njr/rating = 7
Behaviour with -F or with unix-style-paths false
$ fdb tag -F -a "Eiffel Tower" njr/rating=8
$ fdb show -F -a "Eiffel Tower" njr/rating
Object with about="Eiffel Tower":
njr/rating = 8
The same behaviour works with untag:
$ fdb untag -F -a "Eiffel Tower" njr/rating
zero:$ fdb show -F -a "Eiffel Tower" njr/rating
Object with about="Eiffel Tower":
(tag njr/rating not present)
I may have missed something, but as far as I can see, this works reliably. If I have missed something, let me know.
So: if you’ve always liked the look of fdb but disliked its unix-style paths, now might be a good time to get it. And if you already use it, but would prefer to use Fluidinfo-style paths, just add
unix-style-paths false
as the third line of your credentials file.
No comments:
Post a Comment