Sounds interesting, do you have an application in mind? This kind of
library is best explained via an interesting example, IMHO. I'll give
some feedback inline below:
On Aug 26, 2011, at 7:00 PM, Thomas Mayer wrote:
Hello,
inspired by the great effort of Louis-Philippe with Puredis, I have started developping a library for another of the NoSQL databases out there, CouchDB.
CouchDB is a database with a RESTful interface, i.e. you connect to
the database with HTTP requests and depending on the HTTP method you
perform the operations. The data you send to CouchDB for storage and the data you receive back from CouchDB are JSON objects, so (more or less) as a lemma, the library also contains objects for encoding and decoding
JSON data.The current version is online at https://github.com/residuum/CouchPdb
A reason for developping the library is Ubuntu One, as it offers a
free 5GB space and includes a CouchDB database.All is in an early stage of development, so do not expect anything to work, it is still very experimental.
I mainly uploaded it to Github to discuss a few points, where I do not know how to deal with in a manner fitting Pd, especially when it comes to encoding and decoding JSON data:
- How should JSON data be dealt with in general? I am currently just
outputting one long symbol separated by spaces, so an object of {"id":1, "name": "my-name"} becomes id 1 name my-name but {"id":1, "name": "my name", "year":2011} becomes id 1 name my name year 2011 and thus breaks the pattern of "key value key value key value".
I could output this as list, which would make spaces in values not
break the pattern of "key value key value key value" (really?). But is this really a way to represent data in the correct Pd way, i.e. does this data format fit the principle of least surprise?
How about a message per key/value pair? Then you just need to ensure
that the key does not have spaces in it, then the value can be a
symbol, float, list, etc. It is possible to generate symbols with
spaces in them in C, and you can work with them too. The problem
really is you can't save symbols with spaces to a .pd file (unless you
use DesireData)
- How should nested objects and arrays be handled? Should they be
handled at all?
That's pretty tricky... I can't think of any examples in Pd. To start
with, I say get something working with the most simple useful set of
features, then build from there. So ignore it for now, and give
guidelines as to how to format the json for Pd.
- How to implement attachments (binary files) for data? Or should I
forget about this stuff and e.g. store images as base64 encoded
strings? I am asking this one in particular, because one application of the object that came into my mind would be a website to upload pictures
that are downloaded by a Pd patch in an installation in some gallery, or multiple gallery installations worldwide uploading snapshop images and interacting somehow.
You should look at Martin Peach's (net,osc, mrpeach lib) and Bryan
Jurish's (moocow, bytes2any, etc) work with strings. You can send
arbitrary data as lists of floats, where each float is a byte. Using
[binfile] you can write bytes to a file, using bytes2any you can
convert them to strings, and any2bytes for vice versa.
.hc
Please do not read the code ;) I have not programmed C for ~10 years, and I have never coded anything but simple stuff for university. So actually: Read the code and give me pointers (no pun intended) to problematic code.
Best regards, Thomas -- "Prisons are needed only to provide the illusion that courts and
police are effective. They're a kind of job insurance." (Leto II. in: Frank Herbert, God Emperor of Dune) http://www.residuum.org/
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
I have the audacity to believe that peoples everywhere can have three
meals a day for their bodies, education and culture for their minds,
and dignity, equality and freedom for their spirits. - Martin
Luther King, Jr.