#!/usr/bin/env python
import couchdbkit
from couchdbkit.designer import push
import os
# Get the server
server = couchdbkit.Server("http://127.0.0.1:5984")
# Get or create a database
db = server.get_or_create_db('test')
# Prepare a simple view that will return whatever we have stored
view = """
function(doc) {
emit(doc._id, doc);
}
"""
# Setup filesystem directory to store a "view all" _javascript_ file, map.js
cdb_design = "cdb/_design/test"
cdb_view = os.path.join(cdb_design, "views/all")
cdb_map = os.path.join(cdb_view, "map.js")
if not os.path.exists(cdb_view):
os.makedirs(cdb_view)
outfile = open(cdb_map, "w")
outfile.write(view)
outfile.close()
# upload our map.js view to the database
push(cdb_design, db)
# create a test document to store in the database
doc = {
'Test' : 'Boo'
}
# save it
db.save_doc(doc)
# retrieve everything in our database
results = db.view('test/all')
for _doc in results:
print _doc
# delete the doc from the database
print db.delete_doc(_doc.get('value'))
# create 1 more doc so it can be viewed via a web browser
new_doc = {"works" : "Go to http://127.0.0.1:5984/_utils to view db"}
# save
db.save_doc(new_doc)
# if all has gone well, fire up your browser and have a look around
# here: http://127.0.0.1:5984/_utils
On Wed, Mar 14, 2012 at 7:27 PM, Michael Milverton <m.milverton@xxxxxxxxx> wrote:
Okay, will do it this weekend.On 03/13/2012 02:39 PM, Michael Milverton wrote:Thanks,It would be great.
Do you want a small python test script? I used couchdbkit (http://couchdbkit.org/)?
Maybe someone else has some simple test code lying around??-- selinux mailing list selinux@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/selinux
On Tue, Mar 13, 2012 at 10:20 PM, Daniel J Walsh <dwalsh@xxxxxxxxxx> wrote:
-----BEGIN PGP SIGNED MESSAGE-----Ok I was close. I am attaching the patch to show what I added based
Hash: SHA1
on your policy.
iEYEARECAAYFAk9fV5MACgkQrlYvE4MpobPSwwCgr+YU1VPetGI51OehHt4A4VIT
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
8YkAn3Fh1GtxwIiNPqY4yI4qTFlkKgx0
=BB2R
-----END PGP SIGNATURE-----
#!/usr/bin/env python import couchdbkit from couchdbkit.designer import push import os # Get the server server = couchdbkit.Server("http://127.0.0.1:5984") # Get or create a database db = server.get_or_create_db('test') # Prepare a simple view that will return whatever we have stored view = """ function(doc) { emit(doc._id, doc); } """ # Setup filesystem directory to store a "view all" javascript file, map.js cdb_design = "cdb/_design/test" cdb_view = os.path.join(cdb_design, "views/all") cdb_map = os.path.join(cdb_view, "map.js") if not os.path.exists(cdb_view): os.makedirs(cdb_view) outfile = open(cdb_map, "w") outfile.write(view) outfile.close() # upload our map.js view to the database push(cdb_design, db) # create a test document to store in the database doc = { 'Test' : 'Boo' } # save it db.save_doc(doc) # retrieve everything in our database results = db.view('test/all') for _doc in results: print _doc # delete the doc from the database print db.delete_doc(_doc.get('value')) # create 1 more doc so it can be viewed via a web browser new_doc = {"works" : "Go to http://127.0.0.1:5984/_utils to view db"} # save db.save_doc(new_doc) # if all has gone well, fire up your browser and have a look around # here: http://127.0.0.1:5984/_utils
-- selinux mailing list selinux@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/selinux