python - Library needs to store object in a Web session: suggestions on API design -
python - Library needs to store object in a Web session: suggestions on API design - i'm developing openid consumer library [1] job in 2 separate web requests: when user requests authentication library discovers info url provided user. this info used during web request when library finishes authentication. i want advice on how best design library api persisting "discovery information" between 2 requests: i inquire caller provide own session object both calls , library store , read own object it: result = openid.request(session, url) # stores discovery in `session` # ... openid.authenticate(session, auth_data) # reads discovery `session` i don't aesthetically looks inversion of control: bring own buffer, we'll utilize you. also, "session" not well-defined interface , may expose limitations. example, sessions in django default want store json-serializable objects , object representing discovery info of custom class json doesn't ...