Exemplo n.º 1
0
    def why_init(self):
        db = Database('players')

        application = tornado.web.Application([
            (r'/(.*?)/score)', RankingsUpdater),
        ]).listen(1920)
        tornado.ioloop.IOLoop.instance().start()
Exemplo n.º 2
0
 def format_list(self):
     db = Database('tucker')
     response = yield db.list('agenda/html',
                              'nomfup',
                              key='n',
                              limit=3,
                              descending=True)
     print response.body
Exemplo n.º 3
0
    def why_jumpy(self):
        db = Database('players')

        class RankingsUpdater(tornado.web.RequestHandler):
            @tornado.web.asynchronous
            def post(self, player_id):
                self.new_score = int(self.request.body)
                db.get(player_id, callback=self.got_player)

            def got_player(doc, status):
                doc.score = self.new_score
                db.save(doc, callback=self.saved_player)

            def saved_player(conflicts, status):
                db.view('leaderboard/highscores', callback=self.got_highscores)

            def got_highscores(rows, status):
                self.write(json.dumps(rows))
                self.finish()
Exemplo n.º 4
0
 def cords_boilerplate(self):
     from corduroy import Database, NotFound, relax
     people_db = Database('people')  # i.e., http://127.0.0.1:5984/people
Exemplo n.º 5
0
 def changes_seq(self):
     db = Database('watched')
     info = yield db.info()
     print info.update_seq
Exemplo n.º 6
0
 def replicator_convenience(self):
     local_db = Database('localdb')
     yield local_db.push(remote_db,
                         "http://elsewhere.com:5984/remotedb",
                         continuous=True,
                         _id='local-to-remote')
Exemplo n.º 7
0
 def replicate_push(self):
     local_db = Database('localdb')
     remote_db = Database('http://elsewhere.com:5984/remotedb')
     yield local_db.push(remote_db)
     yield local_db.pull(remote_db)
Exemplo n.º 8
0
 def format_show(self):
     db = Database('mannion')
     response = yield db.show('records/csv',
                              '1978-wotw',
                              include_titles=True)
     print response.headers['Content-Type']
Exemplo n.º 9
0
 def query_simple(self):
     db = Database('dosac')
     rows = yield db.view('employees/byname')
     print rows
Exemplo n.º 10
0
    def batch_get(self):
        db = Database('backbench')
        doc_ids = ['ballentine', 'holhurst', 'swain']
        docs = yield db.get(doc_ids)

        print docs[0]
Exemplo n.º 11
0
    def doc_get(self):
        db = Database('underlings')
        ollie = yield db.get('lackey-129')

        print ollie
        print 'Mr. %(first)s %(last)s can be found at %(office)s.' % ollie
Exemplo n.º 12
0
 def db_init(self):
     db = Database('http://127.0.0.1:5984/some_db_name')
     db = Database('some_db_name')