skariel / webalchemy

Modern web development with Python
MIT License
346 stars 21 forks source link

HelloWorldApp shows blank page with webalchemy boilerplate #110

Closed sthzg closed 10 years ago

sthzg commented 10 years ago

I tried the hello world example. When I access the site I seem to successfully access the webalchemy environment, since I see its boilerplate in the web inspector. Still I can't manage to get some elements on the page (like the H1 of the example).

What is the best way of debugging, for example is there a way that I can approve that the initialize method of the HelloWorldApp class gets executed? I tried to put an import pdb; pdb.set_trace() and a print inside, which has no effect. (but maybe that doesn't mean anything).

bildschirmfoto 2014-01-05 um 15 08 44

skariel commented 10 years ago

The example seems to work OK with my system, see image below. What browser are you using, it needs to support websockets to work with Webaclehmy. Debug is currently turned on by default, open the console and see messages delivered. In my console I see the following:

sending message: (index):249
hi, my ID is:807827692082045: and my tabid is:3470183766878635: and my vendor prefix is:webkit (index):250
message received: (index):285
document.app= {};
var __v0=document.createElement("style");
__v0.app= {};
__v0.setAttribute("id","__v0");
__v0.setAttribute("type","text/css");
document.body.appendChild(__v0);
var __v0=document.styleSheets[0];
var __v1=document.createElement("h1");
__v1.textContent="Hello World!!!";
__v1.app= {};
__v1.setAttribute("id","__v1");
document.body.appendChild(__v1);
 (index):286
sending message: (index):249
done 

do you see somthing similar?

image

skariel commented 10 years ago

There are lots of logging messages being printed in the server side if you turn them on like this:

import logging
server.log.setLevel(logging.INFO)

The thing is that since you print inside the Tornado event loop you need to flush the prints. You can print things from your app like this:

import logging
log = logging.getLogger(__name__)
log.setLevel(logging.INFO)

and then...

log.info('Hi there!')

or you can use print and sys.stdout.flush()

Anyway, this seems to work with latest FF, Chrome, Opera, and IE10

sthzg commented 10 years ago

Thanks for your fast answer. I double checked the script and tested it on my local machine. Here it works, so it has something to do with the setup on my remote server. Should have checked that before. Again thanks for your reply.

skariel commented 10 years ago

You're welcome, please keep reporting any issues you have!