Ejemplo n.º 1
0
 def get_conn():
     return_d = Deferred()
     database.connect_box(
         self.boxid, db_user, db_pass).addCallbacks(
             lambda conn: conn_passthru(conn, return_d),
             return_d.errback)
     return return_d
Ejemplo n.º 2
0
        def got_acct(acct):
            if acct == False:
                return self.return_forbidden(request)

            db_user, db_pass = acct

            def check_app_perms(acct):
                token = self.webserver.tokens.new(username,password,boxid,appid,origin,request.getClientIP())
                return self.return_ok(request, {"token":token.id})

            # create a connection pool
            database.connect_box(boxid,db_user,db_pass).addCallbacks(check_app_perms, lambda conn: self.return_forbidden(request))
Ejemplo n.º 3
0
        def got_acct(new_acct):

            if self.best_acct is None:
                self.best_acct = new_acct

            db_user, db_pass = new_acct

            def connected_cb(conn):
                logging.debug("Token get_store connected, returning it.")
                self.connections.append(conn)

                def get_sync():
                    return database.connect_box_sync(self.boxid, db_user, db_pass)

                conns = {"conn": conn, "sync_conn": get_sync}
                store = ObjectStoreAsync(conns, self.username, self.appid, self.clientip)
                result_d.callback(store)

            database.connect_box(self.boxid, db_user, db_pass).addCallbacks(connected_cb, result_d.errback)
Ejemplo n.º 4
0
        def got_acct(new_acct):

            if self.best_acct is None:
                self.best_acct = new_acct

            db_user, db_pass = new_acct

            def connected_cb(conn):
                logging.debug("Token get_store connected, returning it.")
                self.connections.append(conn)

                def get_sync():
                    return database.connect_box_sync(self.boxid, db_user,
                                                     db_pass)

                conns = {"conn": conn, "sync_conn": get_sync}
                store = ObjectStoreAsync(conns, self.username, self.appid,
                                         self.clientip)
                result_d.callback(store)

            database.connect_box(self.boxid, db_user,
                                 db_pass).addCallbacks(connected_cb,
                                                       result_d.errback)
Ejemplo n.º 5
0
Archivo: token.py Proyecto: imclab/indx
 def get_conn():
     return_d = Deferred()
     database.connect_box(self.boxid, db_user, db_pass).addCallbacks(lambda conn: conn_passthru(conn, return_d), return_d.errback)
     return return_d