469,323 Members | 1,665 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

threadsafety in cherrypy with kid

I have just recently discovered CherryPy and Kid (many kudos to the
respective developers!) and am tinkering with them to see what I can
come up with.

The application I eventually want to write will eventually require the
python code to call stored procedures in a database which means I'll
need to run CherryPy with a threadPool so individual database calls
don't block the whole server.

I'm not to that point yet, I'm just getting a feel for what is
possible, and I wanted to make sure the following usage of my Kid
template (named "index") is threadsafe:
from cherrypy import cpg
import kid; kid.enable_import()
from infidel.web import index

class Root(object):

@cpg.expose
def index(self, *args, **kwargs):
count = cpg.request.sessionMap.get('count', 0) + 1
cpg.request.sessionMap['count'] = count
template = index.Template(times=count)
return template.serialize(output='html-strict')
if __name__ == '__main__':
cpg.root = Root()
cpg.server.start(configFile = 'web.ini')
Does it matter that I've done the import of index at the module level
instead of inside the index method? The example at the CherryPy
recipes site does this:
from cherrypy import cpg
import kid

class HomePage:

def index(self):
test = kid.Template(file='test.kid')
test.title = "Test Kid Page"
test.lines = ['qwe','asd','zxc']
return test.serialize(output='xhtml')

index.exposed = True

if __name__ == "__main__":
cpg.root = HomePage()
cpg.server.start()
Is there a qualitative difference between what I've done and what the
examle does?

Aug 18 '05 #1
0 1031

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Remi Delon | last post: by
13 posts views Thread by Charlotte | last post: by
1 post views Thread by infidel | last post: by
2 posts views Thread by infidel | last post: by
reply views Thread by Thomas McLean | last post: by
10 posts views Thread by Vincent Delporte | last post: by
reply views Thread by Bart Van Loon | last post: by
2 posts views Thread by Brian Blais | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.