I’ve been working on a pet project with FluidDB recently and thought I’d post a few observations.
FluidDB is the core technology being developed by a company called FluidInfo. It’s in alpha test and the general idea is a central (I’m loathe to use the word “cloud”) database populated by objects. That’s objects as in things rather than the object oriented programming concept of object. Objects are tagged by users, and those tags define information and relationships between objects.
Each user can build up and tear down their selection of available tags, arranging these tags in a series of namespaces. For example, I have a namespace defined for an application I’m building:
That namespace consists of my root namespace (me, my user name) with a child namespace entitled music. There are no rules on how people structure their namespaces – I could easily call it metaljoe/aural or metaljoe/rhubarb if I wanted. As FluidDB evolves, conventions will naturally arise as people, hopefully, find certain naming styles preferable or popular. For the moment, anything goes.
First, I need to instantiate and bind my proxy to FluidDB. Using The excellent FOM library for Python: (please note that I am using the FluidDB sandbox rather than the live database)
>>> from fom.session import Fluid >>> fluid = Fluid( "http://sandbox.fluidinfo.com" ) >>> fluid.db.client.login( "metaljoe", <password> ) >>> fluid.bind()
I then retrieve my user’s namespace:
>>> from fom.mapping import Namespace >>> namespace = Namespace( u"metaljoe" )
To retrieve the list of child namespaces as either “leaf” names or full paths:
>>> namespace.namespace_names ['music'] >>> namespace.namespace_paths [u'metaljoe/music']
If I want to create a new namespace under the current one, I can do this…
>>> namespace.create_namespace( u"test", u"A test namespace" ) <fom.mapping.Namespace object at 0x743670>
…or if I decide to remove it:
>>> namespace.namespace_names ['music', 'test'] >>> namespace = Namespace( u"metaljoe/test" ) >>> namespace.delete() <FluidResponse (204, 'text/html', None, '')> >>> namespace = Namespace( u"metaljoe" ) >>> namespace.namespace_names ['music']
You’ll notice a little bit of FluidDB’s RESTful API shows through here, because we obtain a 204 (No Content) response code on a successful deletion.
As well as child namespaces, a namespace can have child tags:
>>> namespace = Namespace( u"metaljoe" ) >>> namespace.tag_names 
Hmm, okay, let’s find a better example:
>>> namespace = Namespace( u"metaljoe/music" ) >>> namespace.tag_names ['related_bands', 'source_url', 'band_name']
Or if I want the full path for the tags:
>>> namespace.tag_paths [u'metaljoe/music/related_bands', u'metaljoe/music/source_url', u'metaljoe/music/band_name']
I’ll cover tags another time.
So there we have it, a real quick tour of FluidDB namespaces – add, delete and view namespaces, and find out what child namespaces and tags are present.