application scope objects?

12 views
Skip to first unread message

qwcode

unread,
Jun 23, 2009, 3:39:56 AM6/23/09
to Django users
coming from the java/servlet world, objects can be placed in the
"ServletContext", thereby making their scope *application* level, not
per request. Yes, you have to be conscious of thread safety in
putting an object there, but atleast you have this option. There's
something similar for .Net apps

I guess this is not possible in a django/wsgi app? You can put
objects into the cache, but they'll timeout.

qwcode

unread,
Jun 23, 2009, 5:19:11 PM6/23/09
to Django users
2 examples of where you'd want this:
1) storing a compiled xslt template (which is thread safe) that will
be used repeatedly
2) storing a pylucene IndexSearcher object (which is thread safe)
which are expensive to recreate

from searching the archive, this question is coming up a lot (usually
with the words "global variable") but with no real answers

it makes me think cherrypy (or a java app running in a servlet
container) would be a better choice than django if you need
application scope. cherrypy is a server that doesn't live and die
with the request

qwcode

unread,
Jun 24, 2009, 7:25:47 PM6/24/09
to Django users
sorry to intrude, but the question has come up twice (with 2 different
authors) on the list in the last few months with no replies. I'll try
again on the user list with some different words
Reply all
Reply to author
Forward
0 new messages