예제 #1
0
    def bookmarks_overrides(self, fixture):
        """Various bits of information can be overridden from the defaults when creating a bookmark from a View.
        """
        user_interface = UserInterface(None, '/a_ui', {}, False, 'test_ui')
        view = UrlBoundView(user_interface, '/aview', 'A View title', {})
        bookmark = view.as_bookmark(description='different description',
                                    query_arguments={'arg1': 'val1'},
                                    locale='af')

        # What the bookmark knows
        vassert(bookmark.description == 'different description')
        vassert(bookmark.query_arguments == {'arg1': 'val1'})
        vassert(bookmark.locale == 'af')
예제 #2
0
    def bookmarks(self, fixture):
        """Bookmarks are pointers to Views. You need them, because Views are relative to a UserInterface and
           a Bookmark can, at run time, turn these into absolute URLs. Bookmarks also contain metadata,
           such as the title of the View it points to.
        """
        user_interface = UserInterface(None, '/a_ui', {}, False, 'test_ui')
        view = UrlBoundView(user_interface, '/aview', 'A View title', {})
        bookmark = view.as_bookmark()

        # What the bookmark knows
        vassert(bookmark.href.path == '/a_ui/aview')
        vassert(bookmark.description == 'A View title')
        vassert(bookmark.base_path == '/a_ui')
        vassert(bookmark.relative_path == '/aview')

        # How you would use a bookmark in other views (possibly in other UserInterfaces)
        a = A.from_bookmark(fixture.view, bookmark)
        vassert(str(a.href) == str(bookmark.href))