当前位置: 首页>>代码示例>>Python>>正文


Python rethinkdb.table方法代码示例

本文整理汇总了Python中rethinkdb.table方法的典型用法代码示例。如果您正苦于以下问题:Python rethinkdb.table方法的具体用法?Python rethinkdb.table怎么用?Python rethinkdb.table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rethinkdb的用法示例。


在下文中一共展示了rethinkdb.table方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def create(cls, **kwargs):
        fullname = kwargs.get('fullname')
        email = kwargs.get('email')
        password = kwargs.get('password')
        password_conf = kwargs.get('password_conf')
        if password != password_conf:
            raise ValidationError("Password and Confirm password need to be the same value")
        password = cls.hash_password(password)
        doc = {
            'fullname': fullname,
            'email': email,
            'password': password,
            'date_created': datetime.now(r.make_timezone('+01:00')),
            'date_modified': datetime.now(r.make_timezone('+01:00'))
        }
        r.table(cls._table).insert(doc).run(conn) 
开发者ID:afropolymath,项目名称:papers,代码行数:18,代码来源:models.py

示例2: validate

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def validate(cls, email, password):
        docs = list(r.table(cls._table).filter({'email': email}).run(conn))

        if not len(docs):
            raise ValidationError("Could not find the e-mail address you specified")

        _hash = docs[0]['password']

        if cls.verify_password(password, _hash):
            try:
                token = jwt.encode({'id': docs[0]['id']}, current_app.config['SECRET_KEY'], algorithm='HS256')
                return token
            except JWTError:
                raise ValidationError("There was a problem while trying to create a JWT token.")
        else:
            raise ValidationError("The password you inputed was incorrect.") 
开发者ID:afropolymath,项目名称:papers,代码行数:18,代码来源:models.py

示例3: execute

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def execute(self, quals, columns):

        log_to_postgres('Query Columns:  %s' % columns, DEBUG)
        log_to_postgres('Query Filters:  %s' % quals, DEBUG)

        myQuery = r.table(self.table)\
                   .pluck(self.columns.keys())

        for qual in quals:

            try:
                operatorFunction = getOperatorFunction(qual.operator)
            except unknownOperatorException, e:
                log_to_postgres(e, ERROR)

            myQuery = myQuery.filter(operatorFunction(r.row[qual.field_name], qual.value)) 
开发者ID:rotten,项目名称:rethinkdb-multicorn-postgresql-fdw,代码行数:18,代码来源:rethinkdb_fdw.py

示例4: fetch_account_resource

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def fetch_account_resource(conn, public_key, auth_key):
    try:
        return await r.table('accounts')\
            .get_all(public_key, index='public_key')\
            .max('start_block_num')\
            .merge({'publicKey': r.row['public_key']})\
            .merge({'holdings': fetch_holdings(r.row['holdings'])})\
            .do(lambda account: (r.expr(auth_key).eq(public_key)).branch(
                account.merge(_fetch_email(public_key)), account))\
            .do(lambda account: (account['label'] == "").branch(
                account.without('label'), account))\
            .do(lambda account: (account['description'] == "").branch(
                account.without('description'), account))\
            .without('public_key', 'delta_id',
                     'start_block_num', 'end_block_num')\
            .run(conn)
    except ReqlNonExistenceError:
        raise ApiBadRequest(
            "No account with the public key {} exists".format(public_key)) 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:21,代码来源:accounts_query.py

示例5: fetch_offer_resource

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def fetch_offer_resource(conn, offer_id):
    try:
        return await r.table('offers')\
            .get_all(offer_id, index='id')\
            .max('start_block_num')\
            .do(lambda offer: (offer['label'] == "").branch(
                offer.without('label'), offer))\
            .do(lambda offer: (offer['description'] == "").branch(
                offer.without('description'), offer))\
            .merge({'sourceQuantity': r.row['source_quantity']})\
            .do(lambda offer: (offer['target'] == "").branch(
                offer.without('target'), offer))\
            .do(lambda offer: (offer['target_quantity'] == "").branch(
                offer,
                offer.merge({'targetQuantity': offer['target_quantity']})))\
            .do(lambda offer: (offer['rules'] == []).branch(
                offer, offer.merge(parse_rules(offer['rules']))))\
            .without('delta_id', 'start_block_num', 'end_block_num',
                     'source_quantity', 'target_quantity')\
            .run(conn)
    except ReqlNonExistenceError:
        raise ApiBadRequest("No offer with the id {} exists".format(offer_id)) 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:24,代码来源:offers_query.py

示例6: update_auth_info

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def update_auth_info(conn, email, public_key, update):
    result = await r.table('auth')\
        .get(email)\
        .do(lambda auth_info: r.expr(update.get('email')).branch(
            r.expr(r.table('auth').insert(auth_info.merge(update),
                                          return_changes=True)),
            r.table('auth').get(email).update(update, return_changes=True)))\
        .do(lambda auth_info: auth_info['errors'].gt(0).branch(
            auth_info,
            auth_info['changes'][0]['new_val'].pluck('email')))\
        .merge(_fetch_account_info(public_key))\
        .run(conn)
    if result.get('errors'):
        if "Duplicate primary key `email`" in result.get('first_error'):
            raise ApiBadRequest(
                "Bad Request: A user with that email already exists")
        else:
            raise ApiBadRequest(
                "Bad Request: {}".format(result.get('first_error')))
    if update.get('email'):
        await remove_auth_entry(conn, email)
    return result 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:24,代码来源:auth_query.py

示例7: deleteMonitor

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def deleteMonitor(self, uid, cid, rdb):
        ''' This will delete a specified health check '''
        check = r.table('monitors').get(cid).run(rdb)
        if check['uid'] == uid:
            delete = r.table('monitors').get(cid).delete().run(rdb)
            if delete['deleted'] == 1:
                qdata = {}
                qdata['item'] = check
                qdata['action'] = 'delete'
                qdata['type'] = 'monitor'
                qdata['item']['cid'] = cid
                for dc in ["dc1queue", "dc2queue"]:
                    q1 = r.table(dc).insert(qdata).run(rdb)
                return True
            else:
                return False
        else:
            return False 
开发者ID:Runbook,项目名称:runbook,代码行数:20,代码来源:monitors.py

示例8: get

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def get(self, cid, rdb):
        ''' Get a monitor object by looking it up '''
        results = r.table('monitors').get(cid).run(rdb)
        if results:
            self.cid = cid
            self.name = results['name']
            self.ctype = results['ctype']
            self.uid = results['uid']
            self.url = results['url']
            self.failcount = results['failcount']
            self.data = results['data']
            self.status = results['status']
            if "encrypted" in results:
                self.encrypted = results['encrypted']
            if self.encrypted:
                crypto = Fernet(self.config['CRYPTO_KEY'])
                self.data = json.loads(crypto.decrypt(bytes(self.data)))
            return self
        else:
            return False 
开发者ID:Runbook,项目名称:runbook,代码行数:22,代码来源:monitors.py

示例9: test_already_confirmed

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def test_already_confirmed(self):
        # Ensure user is redirected if already confirmed
        timestamp = time.time()
        token = generate_confirmation_token(
            'test@tester.com', 1, timestamp)
        with self.client:
            self.client.post('/login', data=dict(
                email='test@tester.com', password='password456'
            ), follow_redirects=True)
            user = User()
            user.config = app.config
            user = user.get('username', 'test@tester.com', g.rdb_conn)
            r.table('users').get(user.uid).update(
                {'confirmed': True}).run(g.rdb_conn)
            response = self.client.get(
                '/confirm/'+str(token), follow_redirects=True)
            self.assertEqual(response.status_code, 200)
            self.assertIn('Runbooks', response.data)
            self.assertIn('Account already confirmed. Thank you.',
                          response.data) 
开发者ID:Runbook,项目名称:runbook,代码行数:22,代码来源:test_user.py

示例10: get

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def get(self, method, lookup, rdb):
        '''
        This will return a domains information based on the data provided
        '''
        if method == 'did':
            did = lookup
        else:
            did = self.getDID(lookup, rdb)
        results = r.table('domain').get(did).run(rdb)
        if results:
            self.did = did
            self.domain = results['domain']
            self.apikey = results['apikey']
            self.failover = results['failover']
            self.uid = results['uid']
            self.email = results['email']
            return self
        else:
            return False 
开发者ID:Runbook,项目名称:runbook,代码行数:21,代码来源:domains.py

示例11: deleteReaction

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def deleteReaction(self, uid, rid, rdb):
        ''' This will delete a specified reaction '''
        reaction = r.table('reactions').get(rid).run(rdb)
        if reaction['uid'] == uid:
            delete = r.table('reactions').get(rid).delete().run(rdb)
            if delete['deleted'] == 1:
                qdata = {}
                qdata['item'] = reaction
                qdata['action'] = 'delete'
                qdata['type'] = 'reaction'
                qdata['item']['rid'] = rid
                q1 = r.table('dc1queue').insert(qdata).run(rdb)
                q2 = r.table('dc2queue').insert(qdata).run(rdb)
                return True
            else:
                return False
        else:
            return False 
开发者ID:Runbook,项目名称:runbook,代码行数:20,代码来源:reactions.py

示例12: find

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def find(cls, id):
        return r.table(cls._table).get(id).run(conn) 
开发者ID:afropolymath,项目名称:papers,代码行数:4,代码来源:models.py

示例13: filter

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def filter(cls, predicate):
        return list(r.table(cls._table).filter(predicate).run(conn)) 
开发者ID:afropolymath,项目名称:papers,代码行数:4,代码来源:models.py

示例14: update

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def update(cls, id, fields):
        status = r.table(cls._table).get(id).update(fields).run(conn)
        if status['errors']:
            raise DatabaseProcessError("Could not complete the update action")
        return True 
开发者ID:afropolymath,项目名称:papers,代码行数:7,代码来源:models.py

示例15: delete

# 需要导入模块: import rethinkdb [as 别名]
# 或者: from rethinkdb import table [as 别名]
def delete(cls, id):
        status = r.table(cls._table).get(id).delete().run(conn)
        if status['errors']:
            raise DatabaseProcessError("Could not complete the delete action")
        return True 
开发者ID:afropolymath,项目名称:papers,代码行数:7,代码来源:models.py


注:本文中的rethinkdb.table方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。