rwl / muntjac

A web application GUI toolkit
http://www.muntiacus.org
Apache License 2.0
42 stars 14 forks source link

Error when run #5

Closed ambyte closed 12 years ago

ambyte commented 12 years ago

When I run this code, appear error Blocked attempt to access file: C:\Python27\lib\site-packages\muntjac-1.1.0-py2.7.egg\muntjac\public\VAADIN/widgetsets/org.muntiacus.MuntjacWidgetSet/org.muntiacus.MuntjacWidgetSet.nocache.js

from muntjac.api import Application, Label, Window

class HelloWorld(Application):

    def init(self):
        main = Window('Hello window')
        self.setMainWindow(main)

        main.addComponent(Label('Hello World!'))

if __name__ == '__main__':
    from muntjac.main import muntjac
    muntjac(HelloWorld, nogui=True, forever=True, debug=True)

What I do wrong?

P.S. Sampler work locally is good, point Muntjac to the directory containing the VAADIN folder I did.

rwl commented 12 years ago

The "Blocked attempt to access file:" error is caused by a safety feature that prevents Muntjac from serving resources outside of the VAADIN directory. I can't replicate your error, but it might be a Windows path issue. One option is to try passing a "contextPath" argument to muntjac():

muntjac(HelloWorld, nogui=True, forever=True, debug=True, contextPath='C:\path\to\VAADIN\parent')

You can specify alternative widgetsets too:

muntjac(HelloWorld, nogui=True, widgetset='com.vaadin.demo.sampler.gwt.SamplerWidgetSet')

Let me know if this helps or not.

ambyte commented 12 years ago

If I write contextPath='C:\path\to\VAADIN\parent' then I get this error:

Failed to load the widgetset: path/VAADIN/widgetsets/com.vaadin.demo.sampler.gwt.SamplerWidgetSet/com.vaadin.demo.sampler.gwt.SamplerWidgetSet.nocache.js?1327998905436

But http status code on request "GET path/VAADIN/widgetsets/com.vaadin.demo.sampler.gwt.SamplerWidgetSet/com.vaadin.demo.sampler.gwt.SamplerWidgetSet.nocache.js?1327999624980 HTTP/1.1" is OK 200

The same problem was discussed on vaadin forum

All work fine if I write how in demo app:

class HelloWorld(Application):

    def init(self):
        main = Window('Hello window')
        self.setMainWindow(main)

        main.addComponent(Label('Hello World!'))

helloW = ApplicationServlet(HelloWorld)
urlmap = URLMap({})
urlmap['/'] = helloW
ws_app = DirectoryApp('VAADIN')
urlmap['/VAADIN'] = ws_app

if __name__ == '__main__':
    wsgi_app = ApplicationServlet(HelloWorld, debug=True)

    wsgi_app = SessionMiddleware(urlmap)

    make_server('localhost', 8080, wsgi_app).serve_forever()