Graham Dumpleton
grahamd at dscpl.com.au
Mon Aug 28 07:48:05 EDT 2006
On 28/08/2006, at 8:34 PM, Fredrik Sandin wrote: > Dear Graham, > > yes, the code I gave as an example represents an existing Python > application. It is home-gown, so your suggestion to embed an XML-RPC > server could do the trick, will have a closer look at it. Thanks! > > By the way, why is it so difficult to support persistent objects, > a "state", from one call to the next? The mod_php application itself > has a state, and each user can be associated with a sessid, so the > problem must be that a user could be served by different mod_php > processes from one call to the next? > > In that case, would it not be possible to use the sessid to make > sure that a user is served by the same mod_php process as long > as the session is valid? You can't control to which Apache child process subsequent requests get directed. In terms of what you are trying to do, a mod_python Session object can at least be used to hold a handle of some sort used to identify something in your backend application. Take for example recipe at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81613 In this example the backend framework creates a unique cursor instance identified by an ID. This ID is used by the XML-RPC client to construct a new URL which addresses the cursor instance. The client can then interact with the cursor, with any cursor state maintained until the client says it no longer needs the cursor or the inactivity timer expires at which point the cursor instance self destructs. Now, if mod_python were the client, the ID used to identify the cursor isn't something which you would want to be pushing all the way back to the user web browser in a cookie, as someone else could fake it up and access someone else's cursor. Thus, the ID for the cursor could be stored in the mod_python Session object with it then being available for mod_python handlers to access on each request, no matter which child process handles the request, and mod_python handler acts as XML-RPC client to access backend using ID as identifier in URL. Hope you can follow what I am talking about. Graham
|