> Diez, How does your callback class work? Lets say TG's index()
> controller gets the request.
>
> def index(kw, arg):
> eID = int(kw['employeeID'])
> webDataGetInit(diezCallback)
> webDataGetEmployeeDetails(ID=100)
> return <what?> # some code to tell browser to keep waiting? or may be
> some JS code to poll the server
>
> after 10 seconds lib calls back with:
> diezCallback('100'. {'name':'TG'})
>
> Now, i store this is stored into the session as you said. What happens
> now? how do i access that session from JS? Does that session stay
> active for ever until the web browser does the request for it? Or, is
> the session reply stored into a DB/file and the callback returns.. ?
> Then later on when JS checks, we do a DB query and return the result?
The session is a server-side object, usually in-memory. Whatever request
hits the server and has the proper session key (maintained as a cookie,
and usually transferred using e.g. mochikit, and of course normal
http-requests) can access it. On the server-side!!!
So yes, you return a page that will instruct the browser to poll - there
isn't any other possibility right now. How this is done - via html-meta
tags (refresh) or javascript timercallbacks - that depends on your
taste. I'd prefer the latter. So you need a second method, like this:
@expose(format='json')
def poll_callback_data(self):
session = cherrypy.session
if session.has_key('GetMeDataResults'):
return dict(success=True, session['GetMeDataResults'])
return dict(success=False)
See how the success value determines if the polling was successful.
> What if the session never got invoked or took a very long time that the
> JS poll timed out.. (lets say we limit number of times we poll so
> server isn't DoS'ed?)
The session doesn't get "invoked". The callback gets. And my callback
object is just a function with some extra state - if it never gets
called, you lose the same you lose if that happens for whatever reason
with every other callback passed -a referernce count (actually, you
have one too much)
Diez
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---