Ejemplo n.º 1
0
    def test_default_root_content(self):
        # Default root
        root = AppRoot()
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Default Root</div>')

        # Default child
        class DefaultChild(BaseNode):
            pass

        with self.layer.hook_tile_reg():
            @tile(name='content', interface=DefaultChild, permission='view')
            class DefaultChildContentTile(Tile):
                def render(self):
                    return '<div>Default Child Content</div>'

        root = AppRoot()
        root.factories['1'] = DefaultChild
        root.properties.default_child = '1'
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Default Child Content</div>')

        # Default content tile
        with self.layer.hook_tile_reg():
            @tile(name='mycontent', interface=AppRoot, permission='view')
            class MyRootContentTile(Tile):
                def render(self):
                    return '<div>My Root Content Tile</div>'

        root = AppRoot()
        root.properties.default_content_tile = 'mycontent'
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>My Root Content Tile</div>')

        # Custom root content tile
        with self.layer.hook_tile_reg():
            @tile(name='content', interface=AppRoot, permission='view')
            class RootContentTile(Tile):
                def render(self):
                    return '<div>Root Content</div>'

        root = AppRoot()
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Root Content</div>')
Ejemplo n.º 2
0
    def test_default_root_content(self):
        # Default root
        root = AppRoot()
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Default Root</div>')

        # Default child
        class DefaultChild(BaseNode):
            pass

        with self.layer.hook_tile_reg():

            @tile(name='content', interface=DefaultChild, permission='view')
            class DefaultChildContentTile(Tile):
                def render(self):
                    return '<div>Default Child Content</div>'

        root = AppRoot()
        root.factories['1'] = DefaultChild
        root.properties.default_child = '1'
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Default Child Content</div>')

        # Default content tile
        with self.layer.hook_tile_reg():

            @tile(name='mycontent', interface=AppRoot, permission='view')
            class MyRootContentTile(Tile):
                def render(self):
                    return '<div>My Root Content Tile</div>'

        root = AppRoot()
        root.properties.default_content_tile = 'mycontent'
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>My Root Content Tile</div>')

        # Custom root content tile
        with self.layer.hook_tile_reg():

            @tile(name='content', interface=AppRoot, permission='view')
            class RootContentTile(Tile):
                def render(self):
                    return '<div>Root Content</div>'

        root = AppRoot()
        request = self.layer.new_request()
        with self.layer.authenticated('max'):
            res = render_tile(root, request, 'content')
        self.assertEqual(res, '<div>Root Content</div>')
Ejemplo n.º 3
0
#     (browser.static_resources, 'typeahead/typeahead.bundle.js'),
#     (browser.static_resources, 'cookie_functions.js')
# ]

cfg.merged.js.protected = list()

cfg.merged.css = Properties()
cfg.merged.css.public = list()
cfg.merged.css.protected = list()

cfg.merged.print_css = Properties()
cfg.merged.print_css.public = [(browser.static_resources, 'print.css')]
cfg.merged.print_css.protected = list()

# root node
root = AppRoot()
root.factories['settings'] = AppSettings


class layout_config(object):
    _registry = dict()

    def __init__(self, *for_):
        self.for_ = for_

    def __call__(self, factory):
        for context in self.for_:
            self._registry[context] = factory
        return factory

    @classmethod
Ejemplo n.º 4
0
# ]

cfg.merged.js.protected = list()

cfg.merged.css = Properties()
cfg.merged.css.public = list()
cfg.merged.css.protected = list()

cfg.merged.print_css = Properties()
cfg.merged.print_css.public = [
    (static_resources, 'print.css'),
]
cfg.merged.print_css.protected = list()

# root node
root = AppRoot()
root.factories['settings'] = AppSettings


@implementer(ILayout)
@adapter(Interface)
def default_layout(context):
    layout = Layout()
    layout.mainmenu = True
    layout.mainmenu_fluid = False
    layout.livesearch = True
    layout.personaltools = True
    layout.columns_fluid = False
    layout.pathbar = True
    layout.sidebar_left = ['navtree']
    layout.sidebar_left_grid_width = 3