Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stop crashes in some error cases.

web.ctx.features and context.features was not initialized in some cases
and the app was crashing because of that. Added support for context
defaults to avoid getting into that situation.
  • Loading branch information...
commit 4515cb96415e5198d8c02c837f8f37aa8babf886 1 parent c88302a
@anandology anandology authored
View
8 openlibrary/plugins/openlibrary/code.py
@@ -793,6 +793,13 @@ def setup_logging():
print >> sys.stderr, "Unable to set logging configuration:", str(e)
raise
+def setup_context_defaults():
+ from infogami.utils import context
+ context.defaults.update({
+ 'features': [],
+ 'user': None
+ })
+
def setup():
import home, inlibrary, borrow_home, libraries, stats, support, events, status, merge_editions, authors
@@ -817,6 +824,7 @@ def setup():
import dev_instance
dev_instance.setup()
+ setup_context_defaults()
setup_template_globals()
setup_logging()
logger = logging.getLogger("openlibrary")
View
2  openlibrary/plugins/upstream/utils.py
@@ -580,7 +580,7 @@ def render(c):
@public
def get_random_recent_changes(n):
- if "recentchanges_v2" in web.ctx.features:
+ if "recentchanges_v2" in web.ctx.get("features", []):
changes = _get_recent_changes2()
else:
changes = _get_recent_changes()
Please sign in to comment.
Something went wrong with that request. Please try again.