TravisPaul edited this page Sep 30, 2014 · 15 revisions

NOTE: This page needs updating.

Installing CouchApp for CouchDB

This is a manual for installing couchapp 1 based on CouchDB 2.

1. Installing CouchDB

CouchApp require couchdb 0.9 or later to use it.

To install Couchdb follow documentation from CouchDB wiki .

2. Installing couchapp

Couchapp requires python2.5x/2.6x to work. python 3.x will be supported soon.

2.1 Installing with easy_install

To install couchapp using easy_install you must make sure you have a recent version of setuptools installed (as of this writing, 0.6c6 (0.6a9 on windows) or later):

$ curl -O http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py -U setuptools

To install or upgrade to the latest released version of couchapp:

$ sudo easy_install -U couchapp

2.2 Installing from source

To install couchapp from source, simply use the normal procedure for installing any Python package. Since couchapp uses setuptools, all dependencies (including setuptools itself) will be automatically acquired and installed for you as appropriate.

2.2.1 Fetch sources

You could download latest sources from Github Downloads

Or fetch them with git 5. Therefore we have to install git and then run :

$ git clone git://github.com/couchapp/couchapp.git 
2.2.2 install couchapp
$ python setup.py install

If you’re using a git checkout, it’s recommended to use the setuptools develop command, which will simply activate couchapp directly from your source directory. This way you can do a git fetch or make changes to the source code without re-installing every time:

$ python setup.py develop

2.3 test if couchapp is working

$ couchapp generate test
Generating a new CouchApp in ~/couchdb/test

If you installed from sources, you could also run unittests, in couchapp source folder :

$ python setup.py test

If you see the above output everything is working fine.

3. Installing a couchapp application

Here we show how to install a couchapp application. If you did not run the couchapp generate command, you should do that now.

3.1 generate an empty application

$ couchapp generate test
Generating a new CouchApp in ~/couchapps/test

The next step is to generate the application

3.2 generate the application

$ couchapp push test http://127.0.0.1:5984/myapp
Pushing CouchApp in ~/couchapps/test to design doc:
http://127.0.0.1:5984/myapp/_design/test
Visit your CouchApp here:
http://127.0.0.1:5984/myapp/_design/test/index.html

If you have allready setup authentication you have to add the user and password to the URL:

$ couchapp push test http://username:password@127.0.0.1:5984/myapp
Pushing CouchApp in ~/couchapps/test to design doc:
http://127.0.0.1:5984/myapp/_design/test
Visit your CouchApp here:
http://127.0.0.1:5984/myapp/_design/test/index.html

Let’s check if that worked.

3.3 using curl to check

$ curl http://127.0.0.1:5984/myapp/_design/test

If curl is not available simply install it with apt-get on debian

$ apt-get install curl

If your shell is spammed with a lot of signes, this is the output from the URL http://127.0.0.1:5984/myapp/_design/test. Everything is fine and you have couchapp running.

4. Installing applications from git

Note: if you want to install git on a Debian based system use apt-get install git-arch.

There are several couchapp’s on github. Checkout this one first:

http://github.com/jchris/sofa/tree/master

Now let’s see how to install them. First you have to get the git source. Let’s take sofa from Chris Anderson as an example.

4.1 get the source from git

$ git clone git://github.com/jchris/sofa.git
$ cd sofa
$ couchapp init
$ couchapp push http://127.0.0.1:5984/sofa
Pushing CouchApp in ~/couchapps/sofa to design doc:
http://127.0.0.1:5984/sofa/_design/sofa
Visit your CouchApp here:
http://127.0.0.1:5984/sofa/_design/sofa/_list/index/recent-posts?descending=true&limit=5

Now watch the result under http://127.0.0.1:5984/myapp/_design/sofa/index.html . If you want to create a new post in Sofa, you have to create an user who is allowed to do that. Simply follow the instructions on how to edit the local.ini here.

5. couchapp usage

The main usage of couchapp is as simple as

Usage: couchapp [OPTIONS] [CMD] [CMDOPTIONS] [ARGS,...]

Options:
    -d, --debug 
    -h, --help 
    --version 
    -v, --verbose 
    -q, --quiet 

Commands:
    autopush [OPTION]... [COUCHAPPDIR] DEST
        --no-atomic          send attachments one by one
        --update-delay [VAL] time between each update

    browse   [COUCHAPPDIR] DEST


    clone    [OPTION]...[-r REV] SOURCE [COUCHAPPDIR]
        -r, --rev [VAL] clone specific revision


    generate [OPTION]... [app|view,list,show,filter,function,vendor] [COUCHAPPDIR] NAME
        --template [VAL] template name


    help     

    init     [COUCHAPPDIR]

    push     [OPTION]... [COUCHAPPDIR] DEST
        --no-atomic    send attachments one by one
        --export       don't do push, just export doc to stdout
        --output [VAL] if export is selected, output to the file
        -b, --browse   open the couchapp in the browser
        --force        force attachments sending
        --docid [VAL]  set docid


    pushapps [OPTION]... SOURCE DEST
        --no-atomic    send attachments one by one
        --export       don't do push, just export doc to stdout
        --output [VAL] if export is selected, output to the file
        -b, --browse   open the couchapp in the browser
        --force        force attachments sending


    pushdocs [OPTION]... SOURCE DEST
        --no-atomic    send attachments one by one
        --export       don't do push, just export doc to stdout
        --output [VAL] if export is selected, output to the file
        -b, --browse   open the couchapp in the browser
        --force        force attachments sending


    startapp [COUCHAPPDIR] NAME

    vendor   [OPTION]...[-f] install|update [COUCHAPPDIR] SOURCE
        -f, --force  force install or update


    version  

Configuration File

Defaults for CouchApps can be set in the .couchapprc file in the root of the generated project. The format looks something like this:

{ "env": { "default": { "db": "http://127.0.0.1:5984/my_couchapp_db" } } }

Note: Variables can be substituted in (such as replacing the hard coded db url with $COUCHDB env var) but this expansion happens before JSON parsing so a bad value could break the JSON syntax

Note2: For more information on configuration options in the .couchapprc file see the README.md file in the couchapp root

Resources

1 http://github.com/couchapp/couchapp

2 http://couchdb.apache.org

3 http://peak.telecommunity.com/DevCenter/EasyInstall

4 http://pypi.python.org/pypi

5 http://github.com/

6 http://ftp.de.debian.org/debian/pool/main/g/git-core

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.