User:Eleanorg/2.2/sloganVoting

From XPUB & Lens-Based wiki
< User:Eleanorg
Revision as of 16:29, 25 January 2013 by Eleanorg (talk | contribs) (Created page with "Visualizing consensus, or lack thereof, through typography. ==Code== ===Create db=== Run once, to create a Mongo db and put a few slogans in it to start. <source lang="pytho...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Visualizing consensus, or lack thereof, through typography.

Code

Create db

Run once, to create a Mongo db and put a few slogans in it to start.

#!/usr/bin/python
#-*- coding:utf-8 -*-
 
import pymongo
from pymongo import Connection
 
# create db and add some slogans to it. 
 
#======== create db with slogans
# 
connection = Connection()
myDB = connection['consentSlogans1']
collection = myDB.collection  
 
slogans = [ "YES MEANS YES", "consent is sexy", "no means no"]

for x in range(0,3):
	title = "slogan" + str(x)
	slogan = slogans[x]
 
	entry = {'title': title, 'slogan': slogan, 'tally': ' ' }
	collection.insert(entry)


#======= test it's working

for Entry in myDB.collection.find():
	print Entry