當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。