From 660ee6571df614f0123d1d97e6c869e2334a0771 Mon Sep 17 00:00:00 2001
From: Steve Howell
Date: Fri, 21 Jun 2013 10:52:46 -0400
Subject: [PATCH] Disable embedly everywhere.
(Before it had been disabled only on prod/staging, but we are
removing it everywhere, motivated by making tests run faster.
In particular, the call to embedly_client.is_supported() was
expensive, as it went over the Internet.)
(imported from commit ea12bf6e7ae84ce7e8023a0d314ecc4c07cbc0a8)
---
humbug/settings.py | 6 ++++++
zephyr/lib/bugdown/__init__.py | 20 ++++++++++++--------
zephyr/tests.py | 7 ++++---
3 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/humbug/settings.py b/humbug/settings.py
index fb8d84bf64..142e3c7e57 100644
--- a/humbug/settings.py
+++ b/humbug/settings.py
@@ -577,6 +577,12 @@ if DEPLOYED:
FILE_UPLOAD_MAX_MEMORY_SIZE = 0
+# We are not currently using embedly due to some performance issues, but
+# we are keeping the code on master for now, behind this launch flag.
+# If you turn this back on for dev, you will want it to be still False
+# for running the tests, or you will need to ensure that embedly_client.is_supported()
+# gets called before the tests run.
+USING_EMBEDLY = False
EMBEDLY_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
if DEPLOYED:
diff --git a/zephyr/lib/bugdown/__init__.py b/zephyr/lib/bugdown/__init__.py
index af8f249043..faf8f346f2 100644
--- a/zephyr/lib/bugdown/__init__.py
+++ b/zephyr/lib/bugdown/__init__.py
@@ -24,9 +24,11 @@ from zephyr.lib.bugdown import codehilite, fenced_code
from zephyr.lib.bugdown.fenced_code import FENCE_RE
from zephyr.lib.timeout import timeout, TimeoutExpired
from zephyr.lib.cache import cache_with_key, cache_get_many, cache_set_many
-from embedly import Embedly
-embedly_client = Embedly(settings.EMBEDLY_KEY, timeout=2.5)
+
+if settings.USING_EMBEDLY:
+ from embedly import Embedly
+ embedly_client = Embedly(settings.EMBEDLY_KEY, timeout=2.5)
# Format version of the bugdown rendering; stored along with rendered
# messages so that we can efficiently determine what needs to be re-rendered
@@ -211,14 +213,14 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
return None
def do_embedly(self, root, supported_urls):
- # embed.ly support disabled on prod/staging until it can be
+ # embed.ly support is disabled until it can be
# properly debugged.
#
# We're not deleting the code for now, since we expect to
# restore it and want to be able to update it along with
# future refactorings rather than keeping it as a separate
# branch.
- if settings.DEPLOYED:
+ if not settings.USING_EMBEDLY:
return
# We want this to be able to easily reverse the hashing later
@@ -311,9 +313,10 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
div.set("class", "inline-preview-twitter")
div.insert(0, twitter_data)
continue
- if embedly_client.is_supported(url):
- embedly_urls.append(url)
- continue
+ if settings.USING_EMBEDLY:
+ if embedly_client.is_supported(url):
+ embedly_urls.append(url)
+ continue
# NOTE: The youtube code below is inactive at least on
# staging because embedy.ly is currently handling those
youtube = self.youtube_image(url)
@@ -321,7 +324,8 @@ class InlineInterestingLinkProcessor(markdown.treeprocessors.Treeprocessor):
add_a(root, youtube, url)
continue
- self.do_embedly(root, embedly_urls)
+ if settings.USING_EMBEDLY:
+ self.do_embedly(root, embedly_urls)
class Gravatar(markdown.inlinepatterns.Pattern):
def handleMatch(self, match):
diff --git a/zephyr/tests.py b/zephyr/tests.py
index e841fb52d7..c32696f1ec 100644
--- a/zephyr/tests.py
+++ b/zephyr/tests.py
@@ -2209,12 +2209,14 @@ xxxxxxx