Skip to content

Instantly share code, notes, and snippets.

Forked from adelevie/
Created April 12, 2012 14:37
What would you like to do?
import requests
class Content(object):
def where(self, params={}):
return Query(self).where(params)
def all(self):
return Query(self).all()
class Query(object):
def __init__(self, klass):
self._klass = klass
self._client = Client()
self._criteria = None
self._request = None
def criteria(self):
if not self._criteria:
self._criteria = {}
return self._criteria
def where(self, params={}):
return self
def all(self):
return self.execute()
def request(self):
if not self._request:
self._request = self._client.all(self.criteria())
return self._request
def execute(self):
return self.request().perform()
class Client(object):
def __init__(self):
self._domain = <%= @domain %>
self._params = None
self._url = None
def get(self, id):
self._url = <%= @weary_client.get(:python) %>
return self
def all(self, params={}):
self._params = params
self._url = <%= @weary_client.all(:python) %>
return self
def perform(self):
return requests.get(self._url, params=self._params)
print Content().where({"search_string":"broadband"}).where({"limit":1}).all().text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment