當前位置: 首頁>>代碼示例>>Python>>正文


Python sessioncontroller.SessionController類代碼示例

本文整理匯總了Python中sessions.sessioncontroller.SessionController的典型用法代碼示例。如果您正苦於以下問題:Python SessionController類的具體用法?Python SessionController怎麽用?Python SessionController使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了SessionController類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testSaveSession_08

    def testSaveSession_08 (self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        Application.wikiroot = self.wikiroot
        Application.selectedPage = self.wikiroot[u"Страница 1"]

        controller = SessionController (Application)
        storage = SessionStorage(Application.config)

        storage.save (controller.getCurrentSession(), u"session1")
        storage.save (controller.getCurrentSession(), u"session2")

        otherStorage = SessionStorage(Application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual (len (sessions), 2)

        self.assertEqual (len (sessions["session1"].pages), 1)
        self.assertEqual (sessions["session1"].pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (sessions["session1"].currentTab, 0)

        self.assertEqual (len (sessions["session2"].pages), 1)
        self.assertEqual (sessions["session2"].pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (sessions["session2"].currentTab, 0)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:26,代碼來源:sessions_test.py

示例2: testRestoreReadonly_02

    def testRestoreReadonly_02(self):
        from sessions.sessioncontroller import SessionController

        wiki = WikiDocument.load(self.wikiroot.path, readonly=True)
        self.application.wikiroot = wiki
        self.application.selectedPage = wiki["Страница 1"]

        tabsController = self.application.mainWindow.tabsController
        tabsController.openInTab(wiki["Страница 2"], True)
        tabsController.openInTab(wiki["Страница 1/Страница 3/Страница 4"],
                                 True)
        tabsController.openInTab(wiki["Страница 1/Страница 3"], False)

        controller = SessionController(self.application)
        session = controller.getCurrentSession()

        tabsController.closeTab(1)
        tabsController.closeTab(1)
        tabsController.closeTab(1)

        controller.restore(session)

        self.assertEqual(os.path.abspath(self.application.wikiroot.path),
                         os.path.abspath(self.wikiroot.path))
        self.assertTrue(self.application.wikiroot.readonly)

        self.assertEqual(os.path.abspath(self.application.wikiroot.path),
                         os.path.abspath(self.wikiroot.path))
        self.assertEqual(tabsController.getTabsCount(), 4)
        self.assertEqual(tabsController.getSelection(), 2)

        self.assertEqual(tabsController.getPage(0).title, "Страница 1")
        self.assertEqual(tabsController.getPage(1).title, "Страница 2")
        self.assertEqual(tabsController.getPage(2).title, "Страница 4")
        self.assertEqual(tabsController.getPage(3).title, "Страница 3")
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:35,代碼來源:test_sessions.py

示例3: testSaveSession_04

    def testSaveSession_04 (self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        sessionName1 = u"Имя сессии 1"
        sessionName2 = u"Имя сессии 2"

        tabsController = Application.mainWindow.tabsController
        Application.wikiroot = self.wikiroot

        Application.selectedPage = self.wikiroot[u"Страница 1"]

        controller = SessionController (Application)

        # Сохраним сессию с одной страницей
        SessionStorage(Application.config).save (controller.getCurrentSession(), sessionName1)

        # Сохраним сессию с двумя страницами
        tabsController.openInTab (self.wikiroot[u"Страница 2"], True)
        SessionStorage(Application.config).save (controller.getCurrentSession(), sessionName2)

        otherStorage = SessionStorage(Application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual (len (sessions), 2)

        self.assertEqual (len (sessions[sessionName1].pages), 1)
        self.assertEqual (sessions[sessionName1].pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (sessions[sessionName1].currentTab, 0)

        self.assertEqual (len (sessions[sessionName2].pages), 2)
        self.assertEqual (sessions[sessionName2].pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (sessions[sessionName2].pages[1], self._getPageLink (self.wikiroot[u"Страница 2"]))
        self.assertEqual (sessions[sessionName2].currentTab, 1)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:35,代碼來源:sessions_test.py

示例4: testRemoveSession_02

    def testRemoveSession_02(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        self.application.wikiroot = self.wikiroot
        self.application.selectedPage = self.wikiroot["Страница 1"]

        controller = SessionController(self.application)
        storage = SessionStorage(self.application.config)

        storage.save(controller.getCurrentSession(), "session1")
        storage.save(controller.getCurrentSession(), "session2")

        otherStorage = SessionStorage(self.application.config)
        sessions = otherStorage.getSessions()
        self.assertEqual(len(sessions), 2)

        # Удалим несуществующую сессию. При этом ничего не должно происходить
        storage.remove("session1")

        otherStorage = SessionStorage(self.application.config)
        sessions = otherStorage.getSessions()
        self.assertEqual(len(sessions), 1)
        self.assertEqual(list(sessions.keys())[0], "session2")

        sessions = storage.getSessions()
        self.assertEqual(len(sessions), 1)
        self.assertEqual(list(sessions.keys())[0], "session2")
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:28,代碼來源:test_sessions.py

示例5: testSaveSession_05

    def testSaveSession_05 (self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        tabsController = Application.mainWindow.tabsController
        Application.wikiroot = self.wikiroot

        Application.selectedPage = self.wikiroot[u"Страница 1"]
        tabsController.openInTab (self.wikiroot[u"Страница 2"], True)

        sessionName = u"Имя сессии"
        controller = SessionController (Application)
        session = controller.getCurrentSession()

        # Сохраним сессию дважды под одним и тем же именем
        SessionStorage(Application.config).save (session, sessionName)
        SessionStorage(Application.config).save (session, sessionName)

        otherStorage = SessionStorage(Application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual (len (sessions), 1)
        self.assertEqual (len (sessions[sessionName].pages), 2)
        self.assertEqual (sessions[sessionName].pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (sessions[sessionName].pages[1], self._getPageLink (self.wikiroot[u"Страница 2"]))
        self.assertEqual (sessions[sessionName].currentTab, 1)
        self.assertFalse (sessions[sessionName].readonly)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:28,代碼來源:sessions_test.py

示例6: testSaveSession_02

    def testSaveSession_02(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        tabsController = self.application.mainWindow.tabsController
        self.application.wikiroot = self.wikiroot

        self.application.selectedPage = self.wikiroot["Страница 1"]
        tabsController.openInTab(self.wikiroot["Страница 2"], False)

        sessionName = "Имя сессии"

        controller = SessionController(self.application)
        SessionStorage(self.application.config).save(controller.getCurrentSession(),
                                                     sessionName)

        otherStorage = SessionStorage(self.application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual(len(sessions), 1)
        self.assertEqual(len(sessions[sessionName].pages), 2)
        self.assertEqual(sessions[sessionName].pages[0],
                         self._getPageLink(self.wikiroot["Страница 1"]))
        self.assertEqual(sessions[sessionName].pages[1],
                         self._getPageLink(self.wikiroot["Страница 2"]))
        self.assertEqual(sessions[sessionName].currentTab, 0)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:27,代碼來源:test_sessions.py

示例7: testSaveSession_06

    def testSaveSession_06(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        tabsController = self.application.mainWindow.tabsController

        uid1 = self._getPageLink(self.wikiroot["Страница 1"])
        uid2 = self._getPageLink(self.wikiroot["Страница 2"])

        wiki = WikiDocument.load(self.wikiroot.path, True)
        self.application.wikiroot = wiki

        self.application.selectedPage = wiki["Страница 1"]
        tabsController.openInTab(wiki["Страница 2"], True)

        sessionName = "Имя сессии"
        controller = SessionController(self.application)
        session = controller.getCurrentSession()

        # Сохраним сессию дважды под одним и тем же именем
        SessionStorage(self.application.config).save(session, sessionName)
        SessionStorage(self.application.config).save(session, sessionName)

        otherStorage = SessionStorage(self.application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual(len(sessions), 1)
        self.assertEqual(len(sessions[sessionName].pages), 2)
        self.assertEqual(sessions[sessionName].pages[0], uid1)
        self.assertEqual(sessions[sessionName].pages[1], uid2)
        self.assertEqual(sessions[sessionName].currentTab, 1)
        self.assertTrue(sessions[sessionName].readonly)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:33,代碼來源:test_sessions.py

示例8: testRestore_01

    def testRestore_01 (self):
        from sessions.sessioncontroller import SessionController

        Application.wikiroot = self.wikiroot
        Application.selectedPage = self.wikiroot[u"Страница 1"]

        tabsController = Application.mainWindow.tabsController
        tabsController.openInTab (self.wikiroot[u"Страница 2"], True)

        controller = SessionController(Application)
        session = controller.getCurrentSession()

        uid1 = self._getPageLink (self.wikiroot[u"Страница 1"])
        uid2 = self._getPageLink (self.wikiroot[u"Страница 2"])

        Application.wikiroot = None
        self.assertEqual (tabsController.getTabsCount(), 0)

        controller.restore (session)

        self.assertEqual (os.path.abspath (Application.wikiroot.path), os.path.abspath (self.path))
        self.assertEqual (tabsController.getTabsCount(), 2)
        self.assertEqual (tabsController.getSelection(), 1)

        newsession = controller.getCurrentSession()
        self.assertEqual (newsession.pages[0], uid1)
        self.assertEqual (newsession.pages[1], uid2)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:27,代碼來源:sessions_test.py

示例9: testRename_08

    def testRename_08(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        self.application.wikiroot = self.wikiroot
        self.application.selectedPage = self.wikiroot["Страница 1"]

        controller = SessionController(self.application)
        storage = SessionStorage(self.application.config)

        storage.save(controller.getCurrentSession(), "session1")
        storage.save(controller.getCurrentSession(), "session2")
        storage.rename("session1", "Абырвалг   ")

        otherStorage = SessionStorage(self.application.config)

        sessions = otherStorage.getSessions()
        self.assertEqual(len(sessions), 2)
        self.assertEqual(sorted(sessions.keys())[0], "session2")
        self.assertEqual(sorted(sessions.keys())[1], "Абырвалг")

        sessions = storage.getSessions()
        self.assertEqual(len(sessions), 2)
        self.assertEqual(sorted(sessions.keys())[0], "session2")
        self.assertEqual(sorted(sessions.keys())[1], "Абырвалг")
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:25,代碼來源:test_sessions.py

示例10: testRestore_05

    def testRestore_05(self):
        from sessions.sessioncontroller import SessionController

        self.__createWiki2()
        wiki2 = WikiDocument.load(self.path2, True)

        self.application.wikiroot = self.wikiroot
        self.application.selectedPage = self.wikiroot["Страница 1"]

        tabsController = self.application.mainWindow.tabsController
        tabsController.openInTab(self.wikiroot["Страница 2"], True)

        controller = SessionController(self.application)
        session = controller.getCurrentSession()

        uid1 = self._getPageLink(self.wikiroot["Страница 1"])
        uid2 = self._getPageLink(self.wikiroot["Страница 2"])

        self.application.wikiroot = wiki2
        self.assertEqual(tabsController.getTabsCount(), 1)

        controller.restore(session)

        self.assertEqual(os.path.abspath(self.application.wikiroot.path),
                         os.path.abspath(self.wikiroot.path))
        self.assertEqual(tabsController.getTabsCount(), 2)
        self.assertEqual(tabsController.getSelection(), 1)

        newsession = controller.getCurrentSession()
        self.assertEqual(newsession.pages[0], uid1)
        self.assertEqual(newsession.pages[1], uid2)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:31,代碼來源:test_sessions.py

示例11: testSaveSession_09

    def testSaveSession_09(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        self.application.wikiroot = self.wikiroot
        self.application.selectedPage = self.wikiroot["Страница 1"]

        controller = SessionController(self.application)
        storage = SessionStorage(self.application.config)

        storage.save(controller.getCurrentSession(), "session1")

        tabsController = self.application.mainWindow.tabsController
        tabsController.openInTab(self.wikiroot["Страница 2"], True)
        storage.save(controller.getCurrentSession(), "session2")

        otherStorage = SessionStorage(self.application.config)

        sessions = otherStorage.getSessions()

        self.assertEqual(len(sessions), 2)

        self.assertEqual(len(sessions["session1"].pages), 1)
        self.assertEqual(sessions["session1"].pages[0],
                         self._getPageLink(self.wikiroot["Страница 1"]))
        self.assertEqual(sessions["session1"].currentTab, 0)

        self.assertEqual(len(sessions["session2"].pages), 2)
        self.assertEqual(sessions["session2"].pages[0],
                         self._getPageLink(self.wikiroot["Страница 1"]))
        self.assertEqual(sessions["session2"].pages[1],
                         self._getPageLink(self.wikiroot["Страница 2"]))
        self.assertEqual(sessions["session2"].currentTab, 1)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:33,代碼來源:test_sessions.py

示例12: testGetSessionInfo_01

    def testGetSessionInfo_01 (self):
        from sessions.sessioncontroller import SessionController

        Application.wikiroot = self.wikiroot
        Application.selectedPage = self.wikiroot[u"Страница 1"]

        controller = SessionController(Application)

        session = controller.getCurrentSession()

        self.assertEqual (session.path, os.path.abspath (self.wikiroot.path))
        self.assertEqual (len (session.pages), 1)
        self.assertEqual (session.pages[0], self._getPageLink (self.wikiroot[u"Страница 1"]))
        self.assertEqual (session.currentTab, 0)
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:14,代碼來源:sessions_test.py

示例13: testRename_07

    def testRename_07(self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        self.application.wikiroot = self.wikiroot
        self.application.selectedPage = self.wikiroot["Страница 1"]

        controller = SessionController(self.application)
        storage = SessionStorage(self.application.config)

        storage.save(controller.getCurrentSession(), "session1")
        storage.save(controller.getCurrentSession(), "session2")

        self.assertRaises(ValueError, storage.rename, "session1", "   ")
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:14,代碼來源:test_sessions.py

示例14: testRename_01

    def testRename_01 (self):
        from sessions.sessionstorage import SessionStorage
        from sessions.sessioncontroller import SessionController

        Application.wikiroot = self.wikiroot
        Application.selectedPage = self.wikiroot[u"Страница 1"]

        controller = SessionController (Application)
        storage = SessionStorage(Application.config)

        storage.save (controller.getCurrentSession(), u"session1")
        storage.save (controller.getCurrentSession(), u"session2")

        self.assertRaises (KeyError, storage.rename, u"invalid", u"Абырвалг")
開發者ID:LihMeh,項目名稱:outwiker,代碼行數:14,代碼來源:sessions_test.py

示例15: testInvalidSession_01

    def testInvalidSession_01(self):
        """
        Если нет открытых вики
        """
        from sessions.sessioncontroller import SessionController

        self.application.wikiroot = None
        controller = SessionController(self.application)

        session = controller.getCurrentSession()

        self.assertEqual(session.path, "")
        self.assertEqual(len(session.pages), 0)
        self.assertEqual(session.currentTab, 0)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:14,代碼來源:test_sessions.py


注:本文中的sessions.sessioncontroller.SessionController類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。