couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Holger Krekel <holger.kre...@gmail.com>
Subject Re: writing show/list functions in python
Date Thu, 13 Dec 2012 22:31:38 GMT
Thanks for the info, Alexander.

On a sidenote, instead of deep directory structures, i am using this style
of declaring my map/reduce functions in Python:

    @couch.view("access")
    class packagenames:
        @staticmethod
        def map(doc):
            return doc["_id"]
        @staticmethod
        def reduce(keys, values, rereduce):
            return 1

The decorator just sets an attribute and returns the unmodified class.
Later i scan the module, do a little bit of introspection and push the
functions to _design/access/_view/packagenames.  The @staticmethod is
purely there to allow easy testing (just call packagenames.map(doc) etc. on
an example doc.  If there is interest, i can see to release that code
sometime.

cheers,
holger
--
http://holgerkrekel.net



On Thu, Dec 13, 2012 at 6:24 PM, Alexander Shorin <kxepal@gmail.com> wrote:

> Hi Holger!
>
> Take a look on:
> http://code.google.com/p/couchdb-python/issues/detail?id=146
> it contains up-to-dated query server with support of all design
> function in Python. With latest patch you'll find short rst guide
> about how to start writing Python ddocs and what their differences
> from Javascript ones.
> --
> ,,,^..^,,,
>
>
> On Thu, Dec 13, 2012 at 6:59 PM, Holger Krekel <holger.krekel@gmail.com>
> wrote:
> > Besides view functions, is it possible to write show/list functions in
> > python?
> >
> > I saw and old issue and patch about this at
> > http://code.google.com/p/couchdb-python/issues/detail?id=78
> >
> > But not anything in the docs.  If it's not available is this planned?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message