I see, I definitely misunderstood what you were asking.
There is not a way to retrieve the request from the global scope. Even though App Engine isolates requests to individual threads, ProtoRPC is not able to make that assumption because in theory (and I know it's really theoretical at this point :) a server might be running on a fully muti-threaded non-appengine system.
I recommend that you implement your own and put your request handlers in a decorator. It ought not to be too tricky using threading.local and a global variable. You could write a decorator to help you with it:
_global_state = threadling.local()
def set_service(method):
def set_service_wrapper(self, request):
_global_state.service = self
return method(self, request)
return set_service_wrapper
def get_service():
return _global_state.service
....
class MyService(remote.Service):
@remote.method(MyRequest, MyResponse)
@set_service
def my_method(self, request):
assert self is get_service()
I do like that webapp2 is sensitive to the possibility that a system may not work like App Engine. Maybe ProtoRPC should do something similar and then have such a method. Most users will likely be on App Engine and would benefit as you would.