From 738c6b61cabdcf2e3a5f01e26e510329b122d40d Mon Sep 17 00:00:00 2001 From: Neal Todd Date: Fri, 14 Feb 2014 13:02:17 +0000 Subject: [PATCH 1/2] Fixing md syntax to rst --- README.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 70106564b..a454db209 100644 --- a/README.rst +++ b/README.rst @@ -1,4 +1,7 @@ -[![Build Status](https://travis-ci.org/torchbox/wagtail.png?branch=master)](https://travis-ci.org/torchbox/wagtail) +|BuildStatus|_ + +.. |BuildStatus| image:: https://travis-ci.org/torchbox/wagtail.png?branch=master +.. _BuildStatus: https://travis-ci.org/torchbox/wagtail Wagtail CMS =========== From c4875dfd4d79d3ac54908e5f53cb743c2494c2d3 Mon Sep 17 00:00:00 2001 From: Karl Hobley Date: Fri, 14 Feb 2014 13:09:08 +0000 Subject: [PATCH 2/2] Removed requests dependency --- setup.py | 1 - wagtail/wagtailembeds/embeds.py | 12 ++++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index 7f030492f..e92d9df23 100644 --- a/setup.py +++ b/setup.py @@ -48,7 +48,6 @@ setup( "beautifulsoup4>=4.3.2", "lxml>=3.3.0", "BeautifulSoup==3.2.1", # django-compressor gets confused if we have lxml but not BS3 installed - "requests==2.2.1", ], zip_safe=False, ) diff --git a/wagtail/wagtailembeds/embeds.py b/wagtail/wagtailembeds/embeds.py index d6be04279..c144b39b9 100644 --- a/wagtail/wagtailembeds/embeds.py +++ b/wagtail/wagtailembeds/embeds.py @@ -1,11 +1,12 @@ import sys from importlib import import_module -import requests from django.conf import settings from datetime import datetime from django.utils import six from wagtail.wagtailembeds.oembed_providers import get_oembed_provider from wagtail.wagtailembeds.models import Embed +import urllib2, urllib +import json class EmbedNotFoundException(Exception): pass @@ -91,10 +92,13 @@ def oembed(url, max_width=None): params['maxwidth'] = max_width # Perform request - r = requests.get(provider, params=params) - if r.status_code != 200: + request = urllib2.Request(provider + '?' + urllib.urlencode(params)) + request.add_header('User-agent', 'Mozilla/5.0') + try: + r = urllib2.urlopen(request) + except urllib2.URLError: raise EmbedNotFoundException - oembed = r.json() + oembed = json.loads(r.read()) # Convert photos into HTML if oembed['type'] == 'photo':