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


Python persistence.Session类代码示例

本文整理汇总了Python中empower.persistence.Session的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: add_pnfdev

    def add_pnfdev(self, pnfdev):
        """Add a new PNF Dev to the Tenant.

        Args:
            pnfdev, a PNFDev object

        Returns:
            None

        Raises:
            KeyError, if the pnfdev is not available
        """

        pnfdevs = getattr(self, pnfdev.ALIAS)

        if pnfdev.addr in pnfdevs:
            return

        pnfdevs[pnfdev.addr] = pnfdev

        belongs = TblBelongs(tenant_id=self.tenant_id, addr=pnfdev.addr)

        session = Session()
        session.add(belongs)
        session.commit()
开发者ID:archam,项目名称:empower-runtime,代码行数:25,代码来源:tenant.py

示例2: remove_pnfdev

    def remove_pnfdev(self, pnfdev):
        """Remove a PNFDev from the Tenant.

        Args:
            addr, a PNFDev object

        Returns:
            None
        Raises:
            KeyError, if the pnfdev is not available
        """

        pnfdevs = getattr(self, pnfdev.ALIAS)

        if pnfdev.addr not in pnfdevs:
            return

        del pnfdevs[pnfdev.addr]

        belongs = Session().query(TblBelongs) \
                           .filter(TblBelongs.tenant_id == self.tenant_id,
                                   TblBelongs.addr == pnfdev.addr) \
                           .first()

        session = Session()
        session.delete(belongs)
        session.commit()
开发者ID:archam,项目名称:empower-runtime,代码行数:27,代码来源:tenant.py

示例3: name

    def name(self, name):
        """Set name."""

        session = Session()
        account = session.query(TblAccount) \
                         .filter(TblAccount.username == self.username) \
                         .first()
        account.name = name
        session.commit()
        self._name = name
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:10,代码来源:account.py

示例4: surname

    def surname(self, surname):
        """Set surname."""

        session = Session()
        account = Session().query(TblAccount) \
                           .filter(TblAccount.username == self.username) \
                           .first()
        account.surname = surname
        session.commit()
        self._surname = surname
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:10,代码来源:account.py

示例5: email

    def email(self, email):
        """Set email."""

        session = Session()
        account = Session().query(TblAccount) \
                           .filter(TblAccount.username == self.username) \
                           .first()
        account.email = email
        session.commit()
        self._email = email
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:10,代码来源:account.py

示例6: generate_default_accounts

def generate_default_accounts():
    """Generate default accounts.

    Three default accounts (one root account and two user accounts are created
    the first time the controller is started.
    """

    if not Session().query(TblAccount).all():

        LOG.info("Generating default accounts")

        session = Session()
        session.add(TblAccount(username="root",
                               password="root",
                               role="admin",
                               name="Administrator",
                               surname="",
                               email="[email protected]"))
        session.add(TblAccount(username="foo",
                               password="foo",
                               role="user",
                               name="Foo",
                               surname="",
                               email="[email protected]"))
        session.add(TblAccount(username="bar",
                               password="bar",
                               role="user",
                               name="Bar",
                               surname="",
                               email="[email protected]"))
        session.commit()
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:31,代码来源:core.py

示例7: add_feed

    def add_feed(self):
        """Create new Feed."""

        feed_id = self.feed_id
        RUNTIME.feeds[feed_id] = Feed(feed_id)
        session = Session()
        session.add(TblFeed(feed_id=feed_id,
                            created=RUNTIME.feeds[feed_id].created,
                            updated=RUNTIME.feeds[feed_id].updated))
        session.commit()

        return RUNTIME.feeds[feed_id]
开发者ID:archam,项目名称:empower-runtime,代码行数:12,代码来源:energinoserver.py

示例8: reject_tenant

    def reject_tenant(cls, tenant_id):
        """Reject previously requested Tenant."""

        pending = Session().query(TblPendingTenant) \
            .filter(TblPendingTenant.tenant_id == tenant_id) \
            .first()

        if not pending:
            raise KeyError(tenant_id)

        session = Session()
        session.delete(pending)
        session.commit()
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:13,代码来源:core.py

示例9: add_pnfdev

    def add_pnfdev(self, addr, label):
        """Add PNFDev."""

        if addr in self.pnfdevs:
            raise KeyError(addr)

        self.pnfdevs[addr] = self.PNFDEV(addr, label)

        session = Session()
        session.add(self.TBL_PNFDEV(addr=addr, label=label))
        session.commit()

        return self.pnfdevs[addr]
开发者ID:gastontelfe,项目名称:empower-runtime,代码行数:13,代码来源:pnfpserver.py

示例10: remove_denied

    def remove_denied(self, sta_addr):
        """ Remove entry from ACL. """

        deny = Session().query(TblDeny) \
                        .filter(TblDeny.addr == sta_addr) \
                        .first()
        if not deny:
            raise KeyError(sta_addr)

        session = Session()
        session.delete(deny)
        session.commit()

        del self.denied[sta_addr]
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:14,代码来源:core.py

示例11: remove_allowed

    def remove_allowed(self, sta_addr):
        """ Remove entry from ACL. """

        allow = Session().query(TblAllow) \
                         .filter(TblAllow.addr == sta_addr) \
                         .first()
        if not allow:
            raise KeyError(sta_addr)

        session = Session()
        session.delete(allow)
        session.commit()

        del self.allowed[sta_addr]
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:14,代码来源:core.py

示例12: remove_imsi2mac

    def remove_imsi2mac(self, imsi):
        """Remove IMSI to MAC mapped value from table."""

        imsi2mac = Session().query(TblIMSI2MAC) \
                         .filter(TblIMSI2MAC.imsi == imsi) \
                         .first()
        if not imsi2mac:
            raise KeyError(imsi)

        session = Session()
        session.delete(imsi2mac)
        session.commit()

        del self.imsi2mac[imsi]
开发者ID:5g-empower,项目名称:empower-runtime,代码行数:14,代码来源:core.py

示例13: remove_feed

    def remove_feed(self, feed_id):
        """Remove Feed."""

        if feed_id not in RUNTIME.feeds:
            raise KeyError(feed_id)

        self.bind_feed(feed_id)
        del RUNTIME.feeds[feed_id]

        feed = Session().query(TblFeed) \
                        .filter(TblFeed.feed_id == feed_id) \
                        .first()

        session = Session()
        session.delete(feed)
        session.commit()
开发者ID:archam,项目名称:empower-runtime,代码行数:16,代码来源:energinoserver.py

示例14: add_denied

    def add_denied(self, sta_addr, label):
        """ Add entry to ACL. """

        deny = Session().query(TblDeny) \
                        .filter(TblDeny.addr == sta_addr) \
                        .first()
        if deny:
            raise ValueError(sta_addr)

        session = Session()
        session.add(TblDeny(addr=sta_addr, label=label))
        session.commit()

        acl = ACL(sta_addr, label)
        self.denied[sta_addr] = acl

        return acl
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:17,代码来源:core.py

示例15: add_allowed

    def add_allowed(self, sta_addr, label):
        """ Add entry to ACL. """

        allow = Session().query(TblAllow) \
                         .filter(TblAllow.addr == sta_addr) \
                         .first()
        if allow:
            raise ValueError(sta_addr)

        session = Session()
        session.add(TblAllow(addr=sta_addr, label=label))
        session.commit()

        acl = ACL(sta_addr, label)
        self.allowed[sta_addr] = acl

        return acl
开发者ID:Panagiotis-Kon,项目名称:empower-runtime,代码行数:17,代码来源:core.py


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