> -----Original Message-----
> From: Brian Brown [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 17, 2002 1:26 PM
> To: [EMAIL PROTECTED]
> Subject: [Webware-discuss] Architecture question
>
>
> Greetings all,
>
> It's been a long route to get here -> Perl CGI -> ASP -> Zope
> -> WebWare
> (over the course of many years :), and so far, IMHO, Webware
> is a dream
> come true, just like Python :)
>
> Now on to my question: I am querying Jabber entities for
> information an
> presenting that on my web site... using the web as an
> administrative front
> end to an application that uses Jabber as the messaging
> infrastructure.
>
> My question relates to what would be the best mechanism
> within Webware to
> facilitate sharing a jabber client across the servlets that
> get created to
> service the requests. Right now it seems that every thread is
> getting one,
> so Jabber messages the come in might not show up for the
> thread that is
> servicing my request.
>
> Ideally, I would like to maintain something in the main event
> loop, so the
> socket is maintained.... but I'm not sure what would be
> appropriate, as I'm
> not very familiar with the architecture yet (this is my
> second day using it)
>
> Any thoughts?
>
The usual suggestion when you want a "singleton" object that is shared
across all servlet instances is to just store it in a global variable at
module level. You can either put this variable directly into the module
that contains your servlet, or if you want to share it across multiple
servlets you can put it into a separate module.
It's simple, Pythonic, and it works great. But you do have to keep in mind
thread-safety, since there may be multiple instances of a servlet executing
simultaneously in different threads. If these threads are all using your
singleton object, you will have to consider thread-safety.
As for integrating into the main event loop, that sounds like you'd have to
dive into ThreadedAppServer.py and make some pretty fundamental changes.
Not recommended if you can avoid it.
- Geoff
_______________________________________________
Webware-discuss mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webware-discuss