Certified HTTP API

From Second Life Wiki
Revision as of 15:23, 13 September 2007 by Which Linden (Talk | contribs)

Jump to: navigation, search

Certified HTTP API

This is the ever-evolving api for a Python implementation of Certified HTTP.


Th major problem we face on the client is resumption. If you send a message, then you crash, what makes you not decide to send the same message with a new message-id? If you planned on sending a message, then taking some actions based on the response, how can you ensure that said actions get carried out on resumption? In the general sense, this implies that a certified http client must be able to capture and store a continuation.

There may be a way to capture a continuation automatically, but it seems unlikely that we'll be able to solve that problem in general, much more likely that the developer writing the chttp client will have to write continuation-friendly code. We need to have an API that allows you to conveniently store and restore the enough application state to serve as a continuation, and to unit test that you actually got all the state you needed!

def start_transferring_foo(*args, chttp_context):
   # this context method saves away the non-deterministic thing
   # during the initial execution, and spits out the saved value on subsequent runs
   local = chttp_context.persist(some_non_deterministic_thing)
   response = chttp_context.post(escrow_url, "start transaction")
   coupon_code = local + response['random number']

# this wraps the worker function with another whose signature is *args,
# and constructs a chttp_context upon invocation
# in python 2.5 you would precede start_transferring_foo with @certified_http.resumable


The paradigm on the server is actually a little easier to conceptualize, since we already have a handle method on the server that we expect to be called asynchronously. We still have to be careful about relying on module-level objects and other external contexts.

class Resource(mu.Resource)

def handle_foo(self, req):
    # we're already in a chttp context