Permalink
Browse files

Import shuffle

  • Loading branch information...
1 parent f8f0616 commit 06841b79ee7ea37ccf82d3cc6fbbbeb7bffda629 @lann committed Feb 17, 2011
@@ -1,5 +1,6 @@
-import adapter
-import client
import request
import signing
import util
+
+import adapter
+import client
@@ -1,75 +1 @@
-from oauth_client import request
-
-class RequestAdapter(request.Request):
- """Provide OAuth functionality to a wrapped HTTP request object"""
-
- METHOD_ATTR = None
- URL_ATTR = None
-
- adapted_cls = None
-
- def __init__(self, wrapped, *args, **kwargs):
- self.wrapped = wrapped
- super(RequestAdapter, self).__init__(*args, **kwargs)
-
- # Signing interface
-
- def get_base_string_parts(self):
- """Get base string parts as a list: [method, url, body]
-
- For each of the parts, provide either:
-
- - A method get_request_<part> that returns the value
-
- - A string <PART>_ATTR naming an (optionally callable)
- attribute of self.wrapped
-
- """
-
- parts = []
- for part in ['method', 'url', 'body']:
- method = getattr(self, 'get_request_%s' % part, None)
- attr_name = getattr(self, '%s_ATTR' % part.upper(), None)
- if method:
- val = method()
- elif attr_name:
- val = getattr(self.wrapped, attr_name)
- if callable(val):
- val = val()
- else:
- raise NotImplementedError('get_base_string_parts [%r]' % part)
-
- parts.append(val)
- return parts
-
- # Client interface
-
- @classmethod
- def fetch(cls, url, data=None, method='GET', headers={},
- **signing_parameters):
- """Return a Response object for request and signing parameters"""
-
- raise NotImplementedError('fetch')
-
-class Response(object):
- def __init__(self, content, code=None, headers=None):
- self.content = content
- self.code = int(code or 200)
- self.headers = headers or {}
-
- def __str__(self):
- if hasattr(self.content, 'read'):
- return self.content.read()
- else:
- return str(self.content)
-
-class AdapterMixin(object):
- """Mixin for HTTP request objects that provides request.oauth_sign()"""
-
- oauth_adapter_cls = None # RequestAdapter
-
- def oauth_sign(self, *args, **kwargs):
- parameter_method = kwargs.pop('parameter_method', None)
- wrapper = self.oauth_adapter_cls(self, *args, **kwargs)
- wrapper.add_oauth_params(parameter_method)
- return wrapper
+from base import *
@@ -0,0 +1,75 @@
+from .. import request
+
+class RequestAdapter(request.Request):
+ """Provide OAuth functionality to a wrapped HTTP request object"""
+
+ METHOD_ATTR = None
+ URL_ATTR = None
+
+ adapted_cls = None
+
+ def __init__(self, wrapped, *args, **kwargs):
+ self.wrapped = wrapped
+ super(RequestAdapter, self).__init__(*args, **kwargs)
+
+ # Signing interface
+
+ def get_base_string_parts(self):
+ """Get base string parts as a list: [method, url, body]
+
+ For each of the parts, provide either:
+
+ - A method get_request_<part> that returns the value
+
+ - A string <PART>_ATTR naming an (optionally callable)
+ attribute of self.wrapped
+
+ """
+
+ parts = []
+ for part in ['method', 'url', 'body']:
+ method = getattr(self, 'get_request_%s' % part, None)
+ attr_name = getattr(self, '%s_ATTR' % part.upper(), None)
+ if method:
+ val = method()
+ elif attr_name:
+ val = getattr(self.wrapped, attr_name)
+ if callable(val):
+ val = val()
+ else:
+ raise NotImplementedError('get_base_string_parts [%r]' % part)
+
+ parts.append(val)
+ return parts
+
+ # Client interface
+
+ @classmethod
+ def fetch(cls, url, data=None, method='GET', headers={},
+ **signing_parameters):
+ """Return a Response object for request and signing parameters"""
+
+ raise NotImplementedError('fetch')
+
+class Response(object):
+ def __init__(self, content, code=None, headers=None):
+ self.content = content
+ self.code = int(code or 200)
+ self.headers = headers or {}
+
+ def __str__(self):
+ if hasattr(self.content, 'read'):
+ return self.content.read()
+ else:
+ return str(self.content)
+
+class AdapterMixin(object):
+ """Mixin for HTTP request objects that provides request.oauth_sign()"""
+
+ oauth_adapter_cls = None # RequestAdapter
+
+ def oauth_sign(self, *args, **kwargs):
+ parameter_method = kwargs.pop('parameter_method', None)
+ wrapper = self.oauth_adapter_cls(self, *args, **kwargs)
+ wrapper.add_oauth_params(parameter_method)
+ return wrapper
@@ -1,8 +1,8 @@
import urllib2
-from oauth_client import adapter
-from oauth_client import util
-from oauth_client.request import ENTITY_BODY_CONTENT_TYPE
+import base as adapter
+from .. import util
+from ..request import ENTITY_BODY_CONTENT_TYPE
class Adapter(adapter.RequestAdapter):
# Signing interface

0 comments on commit 06841b7

Please sign in to comment.