models.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:pyfc4 作者: ghukill 项目源码 文件源码
def start_txn(self, txn_name=None):

        '''
        Request new transaction from repository, init new Transaction, 
        store in self.txns

        Args:
            txn_name (str): human name for transaction

        Return:
            (Transaction): returns intance of newly created transaction
        '''

        # if no name provided, create one
        if not txn_name:
            txn_name = uuid.uuid4().hex

        # request new transaction
        txn_response = self.api.http_request('POST','%s/fcr:tx' % self.root, data=None, headers=None)

        # if 201, transaction was created
        if txn_response.status_code == 201:

            txn_uri = txn_response.headers['Location']
            logger.debug("spawning transaction: %s" % txn_uri)

            # init new Transaction, and pass Expires header
            txn = Transaction(
                self, # pass the repository
                txn_name,
                txn_uri,
                expires = txn_response.headers['Expires'])

            # append to self
            self.txns[txn_name] = txn

            # return 
            return txn
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号