Skip to content

Commit

Permalink
Rename parent response class to BaseResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
joncotton committed Mar 20, 2014
1 parent ee31c82 commit 833c401
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ returned. If you want the response object itself, use
``embed_obj.get_response()``.

``embed_obj.response`` is the way to access the response data. This will be a
subclass of the ``Response`` object with a standard set of attributes.
subclass of the ``BaseResponse`` object with a standard set of attributes.
``is_valid()`` will be False in cases where the API had a problem, didn't
return data, 404'd, etc. ``is_fresh()`` will be True when the response is
fresh off the wire. It's used to differentiate from database cached response
data and you can probably ignore it. ``type`` and ``provider`` are
``EmbedType`` and ``Provider`` model objects. ``_data`` holds the actual raw
response in JSON. The goal is to never directly access this. Instead, the
Response class is subclassed by each backend/API and tailored to parse the
BaseResponse class is subclassed by each backend/API and tailored to parse the
raw data into standardized attributes. This way who cares if it's YouTube or
Vimeo, access the object the same and share the templates. These attributes
return an empty string when nothing is available and are therefore
Expand Down
2 changes: 1 addition & 1 deletion armstrong/apps/embeds/backends/base_response.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ..models import EmbedType, Provider


class Response(object):
class BaseResponse(object):
_type_field = 'type'
_provider_field = 'provider_name'

Expand Down
4 changes: 2 additions & 2 deletions armstrong/apps/embeds/backends/default.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from . import proxy
from .base_response import Response
from .base_response import BaseResponse


class DefaultResponse(Response):
class DefaultResponse(BaseResponse):
def is_valid(self):
return True

Expand Down
4 changes: 2 additions & 2 deletions armstrong/apps/embeds/backends/embedly.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from .. import logger
from . import proxy, InvalidResponseError
from .base_response import Response
from .base_response import BaseResponse


class EmbedlyResponse(Response):
class EmbedlyResponse(BaseResponse):
def is_valid(self):
return not (
not self._data or
Expand Down
4 changes: 2 additions & 2 deletions armstrong/apps/embeds/backends/twitter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import proxy
from .base_response import Response
from .base_response import BaseResponse


TWITTER_SCRIPT_TAG = '<blockquote class="twitter-tweet">' \
Expand All @@ -8,7 +8,7 @@
'charset="utf-8"></script>'


class TwitterResponse(Response):
class TwitterResponse(BaseResponse):
def is_valid(self):
return True

Expand Down
4 changes: 2 additions & 2 deletions armstrong/apps/embeds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def response(self, response):
but there is no need to re-write the metadata.
"""
from .backends.base_response import Response
if not isinstance(response, Response):
from .backends.base_response import BaseResponse
if not isinstance(response, BaseResponse):
raise InvalidResponseError("not a Response object")

if self.response == response:
Expand Down
4 changes: 2 additions & 2 deletions tests/backends/base_response.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from armstrong.apps.embeds.backends.base_response import Response
from armstrong.apps.embeds.backends.base_response import BaseResponse
from ._common import CommonResponseTestCaseMixin
from .._utils import TestCase


class ResponseTestCase(CommonResponseTestCaseMixin, TestCase):
response_cls = Response
response_cls = BaseResponse

def test_is_valid_is_not_implemented(self):
self.assertRaises(NotImplementedError, self.response_cls().is_valid)
Expand Down

0 comments on commit 833c401

Please sign in to comment.