How to use the awe.view.CustomElement 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_parser.py View on Github external
def test_is_parsable():
    assert parser.is_parsable('')
    assert parser.is_parsable({})
    assert parser.is_parsable([])

    assert not parser.is_parsable(None)
    assert not parser.is_parsable(view.Element)
    assert not parser.is_parsable(view.CustomElement)
github dankilman / awe / tests / test_parser.py View on Github external
def test_parse_custom_element():
    class TestElement(view.CustomElement):
        @classmethod
        def _js(cls):
            pass

    page = Page()
    page.register(TestElement)
    result = page.new('TestElement')
    assert isinstance(result, TestElement)
github dankilman / awe / awe / registry.py View on Github external
def _get_id_and_store(self, obj, obj_id):
        obj_id = obj_id or getattr(obj, 'id', str(id(obj)))
        if isinstance(obj, view.Root):
            store = self.roots
        elif isinstance(obj, view.Element):
            store = self.elements
        elif isinstance(obj, type) and issubclass(obj, view.CustomElement):
            store = self.element_types
        elif isinstance(obj, variables.Variable):
            store = self.variables
        elif callable(obj):
            store = self.functions
        else:
            raise RuntimeError('No registry is defined for objects of type {}'.format(type(obj).__name__))
        return obj_id, store