I'm mucking around with desktopcouch at the moment, and I think I'm
reaching the stage where it would really help to look at the code for
a functioning application. Where might I find an example of an app
written particularly for desktopcouch?
Some of the questions on my mind are:
- How to map from desktopcouch records to application-level objects
- How to best work with map & reduce functions, both in terms of
storing them in VC, but also loading them without having 'if
db.view_exists()'-style code everywhere
Bonus points if the app has good unit tests.
I had a quick trawl around the Ubuntu One code I'm allowed to see, and
couldn't find anything that even mentioned desktopcouch (it was a
quick look). I've also had a look at Ryan Paul's branch of GTG that
adds couch support, but that doesn't work, and GTG's design makes it
hard to get answers to those questions.
Thanks,
jml
I'll second Jonathan's request. I'd enjoy paging through some example
code myself.
Jonathan, have you looked at the Quickly project? https://launchpad.net/quickly
Rumor has it that it'd have the sorts of things you are talking about.
To desktopcouch developers: there are a lot of CouchDB users who are
web-developers. If there was a tutorial like: "So you understand the
web and CouchDB, let's learn desktop programming" I bet it'd get a lot
of play.
I for one haven't the foggiest idea how I'd start writing a desktop
app for Ubuntu, aside from reading the link I posted above.
Chris
>
> Some of the questions on my mind are:
> - How to map from desktopcouch records to application-level objects
> - How to best work with map & reduce functions, both in terms of
> storing them in VC, but also loading them without having 'if
> db.view_exists()'-style code everywhere
>
> Bonus points if the app has good unit tests.
>
> I had a quick trawl around the Ubuntu One code I'm allowed to see, and
> couldn't find anything that even mentioned desktopcouch (it was a
> quick look). I've also had a look at Ryan Paul's branch of GTG that
> adds couch support, but that doesn't work, and GTG's design makes it
> hard to get answers to those questions.
>
> Thanks,
> jml
>
> --
>
> You received this message because you are subscribed to the Google Groups "Desktop CouchDB" group.
> To post to this group, send email to desktop...@googlegroups.com.
> To unsubscribe from this group, send email to desktop-couch...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/desktop-couchdb?hl=en.
>
>
>
--
Chris Anderson
http://jchrisa.net
http://couch.io
Indeed. I've even submitted patches :)
> Rumor has it that it'd have the sorts of things you are talking about.
>
Not quite. It helps you get started quickly, but it doesn't yet have
things to help you say "I'm going to have a document that looks like
this, go make me some boilerplate".
> To desktopcouch developers: there are a lot of CouchDB users who are
> web-developers. If there was a tutorial like: "So you understand the
> web and CouchDB, let's learn desktop programming" I bet it'd get a lot
> of play.
>
> I for one haven't the foggiest idea how I'd start writing a desktop
> app for Ubuntu, aside from reading the link I posted above.
>
Quickly is a great application for this getting started part. It's the
next part that I need help with.
jml
At the moment, DC is new enough that it's hard to point at such an
application (it was only released two months ago, remember :)) As you
note, the Ubuntu One client does a little DC (when the applet starts up,
it creates a desktopcouch pairing between your machine and Ubuntu One if
you're paired for filesync); see /usr/bin/ubuntuone-client-applet for
that. Ryan's not only worked on desktopcouch in GTG (and written the Ars
article about it, which I imagine you've read: http://arst.ch/b0l if
not) but has also been working on desktopcouch in gwibber, but again I
don't think that's reached public branches yet. Every Quickly app uses
desktopcouch for storing preferences, and can relatively easily also use
the CouchGrid widget for rendering data in a Gtk treeview widget, and
that code might be a place to start.
> - How to best work with map& reduce functions, both in terms of
> storing them in VC, but also loading them without having 'if
> db.view_exists()'-style code everywhere
You've discovered the idea of storing this stuff on the filesystem,
which is The Right Way to do this ;)
sil
Fair enough. In which case, I'll be a little more adventurous and a
little more rigorous about taking notes, asking questions and filing
bugs. :)
jml
Interesting.
One of the things I've discovered in my researches is couchdb.schema,
which looks to be exactly what you describe. Does your work interact
with couchdb.schema at all?
jml
It perhaps does not have enough signs pointing to it, but there is some
API and documentation for this part included with desktopcouch:
code:
doctest:
Basically, it provides a relatively simple way to set up mappings
between fields in your application objects, and fields in a desktopcouch
record object.
Please let me know if there are things that are unclear, or
functionality that is missing.
Thanks. I'll have a play & get back to you.
jml
class ContactMapper(ClassMapper):And a group that contains contacts can be mapped in the following way:
def __init__(self):
ClassMapper.__init__(self, Contact, ‘contact‘)
self.map(‘first_name‘, ‘name‘)
self.map(‘middle_name‘, ‘mname‘)
self.map(‘last_name‘, ‘surname‘) # can be a property instead of an attribute
self.id(‘id‘) # can be any property no necesarily id
self.init(Contact, -1, ‘‘, ‘‘, ‘‘)
class GroupMapped(ClassMapper):
def __init__(self):
ClassMapper.__init__(self, Group, ‘group‘)
self.map(‘name‘, ‘name‘)
# we reference the contact in the group_contacts field
self.references(‘group_contacts‘, ‘contacts‘)
The mappings allow to use more complicated documents to be generated which may contain: