Beispiel #1
0
def display_jigna(context, template, size=None):
    """
    A `display_html` style method to show rich jigna display for the objects
    within the context.
    """
    PORT = get_free_port()

    app = WebApp(context=context, template=template, port=PORT)
    application = app.create_application()
    application.listen(app.port)

    width, height = size or template.recommended_size
    html = ('<iframe src="http://localhost:%s" width=%s height=%s></iframe>'
            % (PORT, width, height))

    return HTML(html)
Beispiel #2
0
def display_jigna(context, template, size=None):
    """
    A `display_html` style method to show rich jigna display for the objects
    within the context.
    """
    PORT = get_free_port()

    app = WebApp(context=context, template=template, port=PORT)
    application = app.create_application()
    application.listen(app.port)

    width, height = size or template.recommended_size
    html = ('<iframe src="http://localhost:%s" width=%s height=%s></iframe>' %
            (PORT, width, height))

    return HTML(html)
    from selenium import webdriver
except ImportError:
    raise unittest.SkipTest("Tornado not installed")

# Local imports.
from jigna.api import Template, WebApp
from jigna.utils.web import get_free_port
from test_jigna_qt import TestJignaQt, Person, body_html

class TestJignaWebSync(TestJignaQt):
    @classmethod
    def setUpClass(cls, async=False):
        ioloop = IOLoop.instance()
        fred = Person(name='Fred', age=42)
        template = Template(body_html=body_html, async=async)
        port = get_free_port()
        app = WebApp(template=template, context={'model':fred})
        app.listen(port)

        # Start the tornado server in a different thread so that we can write
        # test statements here in the main loop
        t = Thread(target=ioloop.start)
        t.setDaemon(True)
        t.start()

        browser = webdriver.Firefox()
        browser.get('http://localhost:%d'%port)
        cls.app = app
        cls.fred = fred
        cls.browser = browser