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


Python Registry.rollback方法代码示例

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


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

示例1: test_organisation_oversubscribes_to_archive

# 需要导入模块: from cloudhands.common.connectors import Registry [as 别名]
# 或者: from cloudhands.common.connectors.Registry import rollback [as 别名]
 def test_organisation_oversubscribes_to_archive(self):
     session = Registry().connect(sqlite3, ":memory:").session
     archive = session.query(Archive).filter(
         Archive.name == "NITS").first()
     org = session.query(Organisation).one()
     subs = [
         Subscription(
             uuid=uuid.uuid4().hex,
             model=cloudhands.common.__version__,
             organisation=org,
             provider=archive),
         Subscription(
             uuid=uuid.uuid4().hex,
             model=cloudhands.common.__version__,
             organisation=org,
             provider=archive)]
     session.add_all(subs)
     self.assertRaises(
         sqlalchemy.exc.IntegrityError, session.commit)
     session.rollback()
     self.assertEqual(0, len(org.subscriptions))
开发者ID:cedadev,项目名称:cloudhands-common,代码行数:23,代码来源:test_schema.py

示例2: mailer

# 需要导入模块: from cloudhands.common.connectors import Registry [as 别名]
# 或者: from cloudhands.common.connectors.Registry import rollback [as 别名]
    def mailer(self):
        log = logging.getLogger(__name__ + ".mailer")
        session = Registry().connect(sqlite3, self.args.db).session
        initialise(session)
        actor = session.query(Component).filter(
            Component.handle=="identity.controller").one()
        invited = session.query(MembershipState).filter(
            RegistrationState.name == "invited").one()
        while True:
            unsent = [
                i for i in session.query(Membership).all()
                if i.changes[-1].state.name == "created"]
            for mship in unsent:
                try:
                    user = mship.changes[-1].actor
                    email = session.query(EmailAddress).join(Touch).join(User).filter(
                        User.id == user.id).order_by(desc(Touch.at)).first().value
                    host = "http://{}:8080".format(platform.node()) #  FIXME
                except Exception as e:
                    log.error(e)
                    break
                else:
                    msg = (email, host, mship.uuid)
                    log.debug(msg)
                    now = datetime.datetime.utcnow()
                    act = Touch(artifact=mship, actor=actor, state=invited, at=now)
                    yield from self.emailQ.put(msg)
                    try:
                        session.add(act)
                        session.commit()
                    except Exception as e:
                        log.error(e)
                        session.rollback()
                        break

            log.debug("Waiting for {}s".format(self.args.interval))
            yield from asyncio.sleep(self.args.interval)
开发者ID:cedadev,项目名称:cloudhands-web,代码行数:39,代码来源:observer.py

示例3: test_organisation_unsubscribes_from_archive

# 需要导入模块: from cloudhands.common.connectors import Registry [as 别名]
# 或者: from cloudhands.common.connectors.Registry import rollback [as 别名]
    def test_organisation_unsubscribes_from_archive(self):
        session = Registry().connect(sqlite3, ":memory:").session
        archive = session.query(Archive).filter(
            Archive.name == "NITS").first()
        self.assertTrue(archive)
        org = session.query(Organisation).one()
        subs = Subscription(
            uuid=uuid.uuid4().hex,
            model=cloudhands.common.__version__,
            organisation=org, provider=archive)
        session.add(subs)
        session.commit()

        session.query(Subscription).filter(
            Subscription.organisation_id == org.id).filter(
            Subscription.provider_id == archive.id).delete()
        session.commit()

        self.assertEqual(
            0, session.query(Subscription, Organisation, Archive).filter(
            Organisation.id == org.id).filter(
            Archive.id == archive.id).count())
        session.rollback()
        self.assertEqual(0, len(org.subscriptions))
开发者ID:cedadev,项目名称:cloudhands-common,代码行数:26,代码来源:test_schema.py

示例4: open

# 需要导入模块: from cloudhands.common.connectors import Registry [as 别名]
# 或者: from cloudhands.common.connectors.Registry import rollback [as 别名]
        Organisation.name == args["organisation"]).first()
    if org is None:
        channel.send("No org named {}".format(args["organisation"]))
        channel.send(None)
    else:
        channel.send(("organisation", org.uuid, org.name))

        with open(args["path"], 'r') as input_:
            objs = rson.loads(input_.read())
            for obj in objs:
                try:
                    session.add(
                        CatalogueItem(
                            name=obj["name"].strip(),
                            description=obj["description"].strip(),
                            note=obj["note"].strip(),
                            logo="headless",
                            organisation=org,
                            natrouted=obj["natrouted"],
                            uuid=obj["uuid"],
                        ))
                    session.commit()
                    channel.send((obj["uuid"], obj["name"].strip()))
                except Exception as e:
                    channel.send(str(e))
                    session.rollback()
                finally:
                    session.flush()

    channel.send(None)
开发者ID:cedadev,项目名称:cloudhands-ops,代码行数:32,代码来源:catalogadmin.py


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