当前位置: 首页>>代码示例>>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;未经允许,请勿转载。