Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge fluidinfo.py and gae_fluidinfo.py #2

Open
gridaphobe opened this issue Aug 5, 2011 · 1 comment
Open

Merge fluidinfo.py and gae_fluidinfo.py #2

gridaphobe opened this issue Aug 5, 2011 · 1 comment

Comments

@gridaphobe
Copy link
Contributor

There's quite a bit of duplicate code between the two. I'd like to reorganize everything such that I can do the following:

# not on gae
>>> import fluidinfo as fi
>>> r = fi.get('/about/...')
>>> r.status
200
>>> r.body
42

# on gae
>>> import fluidinfo.gae as fi
>>> r = fi.get('/about/...')
>>> r.status
200
>>> r.body
42

# gae asynchronous
>>> import fluidinfo.gae as fi
>>> rpc = fi.get('/about/...', async=True)
# later
>>> r = rpc.result()
>>> r.status
200
>>> r.body
42

Basically the only change was the import. Most of this will be straightforward, but we'll need a Response class to present a standard interface for users whether they are on gae or somewhere else.

@ntoll
Copy link
Member

ntoll commented Aug 5, 2011

Looks good to me :-)

How about:

   >>> from fluidinfo import session
   >>> from fluidinfo.caller import gae, httplib2
   >>> s1 = session(caller=gae)
   >>> s2 = session(caller=httplib2)
   >>> s3 = session() // defaults to something nice
   >>> def onSuccess(result):
   ...  # do something
   >>> s1.get("/users/ntoll", onSuccess=onSuccess) #async
   >>> result = s2.get("/users/ntoll")

Basically, different swappable backends that do the actual HTTP stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants