How to use the awe.view function in awe

To help you get started, we’ve selected a few awe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dankilman / awe / tests / test_element.py View on Github external
def test_base():
    page = Page()

    test_data = {'data_key': 'value1'}
    test_props = {'props_key': 'value2'}
    style = {'s1': 'v1'}
    test_id = 'test_id'

    class TestElement(view.Element):
        def _init(self):
            self.update_data(test_data)
            self.update_props(test_props)

    class TestElement2(view.Element):
        pass

    class TestElement4(view.Element):
        def _init(self, arg1, arg2):
            self.arg1 = arg1
            self.arg2 = arg2

    assert page.root is page
    assert page.root_id == 'root'
    assert page.index == 0
    assert page._version == 0
github dankilman / awe / tests / test_parser.py View on Github external
def test_parser_string_input():
    page = Page()
    result = page.new('Divider')
    assert isinstance(result, view.Divider)
github dankilman / awe / awe / parser.py View on Github external
def _is_element_type(self, str_obj):
        return (
            str_obj in self.registry.element_types or
            str_obj in view.builtin_element_types
        )
github dankilman / awe / awe / page.py View on Github external
:param offline: Offline mode means start/block don't do anything. Useful when exporting directly from python.
        :param serializers: Custom serializers for custom element implementations.
        """
        super(Page, self).__init__(owner=self, element_id='root')
        self._registry = registry.Registry()
        self._register(self)
        self._offline = (offline or os.environ.get('AWE_OFFLINE'))
        self._port = port
        self._title = title
        self._style = self._set_default_style(style, width)
        self._element_updater = element_updater.ElementUpdater()
        self._parser = parser.Parser(
            registry=self._registry
        )
        self._encoder = encoding.Encoder(
            element_cls=view.Element,
            serializers=serializers
        )
        self._message_handler = messages.MessageHandler(
            registry=self._registry,
            dispatch=self._dispatch
        )
        self._custom_component = custom.CustomComponentHandler(
            registry=self._registry,
            encoder=self._encoder
        )
        self._exporter = export.Exporter(
            export_fn=export_fn,
            get_initial_state=self._get_initial_state,
            custom_component=self._custom_component,
            encoder=self._encoder
        )