Example #1
0
        def assemble(self):
            self.define_page(HTML5Page).use_layout(BasicPageLayout())

            step1 = self.define_view('/firstStepOfDetour', title='Step 1', detour=True)
            step1.set_slot('main', A.factory_from_bookmark(step1.as_bookmark(self)))

            home = self.define_view('/initial', title='View a')
            home.set_slot('main', A.factory_from_bookmark(step1.as_bookmark(self)))
Example #2
0
 def assemble(self, bookmark=None):
     self.bookmark = bookmark
     slot_definitions = {
         'main': A.factory_from_bookmark(self.bookmark)
     }
     self.define_view('/initial',
                      title='View a',
                      slot_definitions=slot_definitions)
Example #3
0
    def bookmarks_support_such_fragments(self, fixture):
        """Page-internal bookmarks support such bookmarkable widgets.

           These Bookmarks usually do not affect an URL - they just set widget states in different ways,
           depending on whether the client has javascript support or not.
           However, if a page was opened using the widget arguments on the querystring, a bookmark that would
           normally only have changed that argument on the hash will point to a new
           url on which the argument has been removed from the querystring and changed on the hash.
        """

        internal_bookmark = Bookmark.for_widget(
            'an ajax bookmark', query_arguments={'fancy_state': 2})
        normal_bookmark = Bookmark('/', '', 'a normal bookmark')

        # You can query whether a bookmark is page_internal or not
        vassert(internal_bookmark.is_page_internal)
        vassert(not normal_bookmark.is_page_internal)

        # page-internal bookmarks must be added to normal ones to be useful
        usable_bookmark = normal_bookmark + internal_bookmark

        wsgi_app = fixture.new_wsgi_app(
            widget_factory=A.factory_from_bookmark(usable_bookmark))

        # Case: when rendered without javascript
        browser = Browser(wsgi_app)
        browser.open('/')

        a = browser.lxml_html.xpath('//a')[0]
        vassert(a.attrib['href'] == '/?fancy_state=2')
        vassert(a.text == 'an ajax bookmark')

        # Case: when rendered in a browser with javascript support
        fixture.reahl_server.set_app(wsgi_app)
        fixture.driver_browser.open('/')
        vassert(
            fixture.driver_browser.is_element_present(
                "//a[@href='/#fancy_state=2']"))
        vassert(not fixture.driver_browser.is_element_present(
            "//a[@href='/?fancy_state=2']"))

        # Case: when the argument was given on the query string of the current page
        fixture.driver_browser.open('/?fancy_state=4')
        vassert(
            fixture.driver_browser.is_element_present(
                "//a[@href='/#fancy_state=2']"))
Example #4
0
 def assemble(self, bookmark=None):
     self.bookmark = bookmark
     self.define_view('/initial', title='View a').set_slot('main', A.factory_from_bookmark(self.bookmark))