From d7239d665e6781d7b84ecfde3fd5d7d1831de284 Mon Sep 17 00:00:00 2001 From: Chris Czub Date: Mon, 9 Nov 2015 15:07:08 -0500 Subject: [PATCH] Add new contentviews' content type mappings --- libmproxy/contentviews.py | 10 ++++++++++ test/test_contentview.py | 1 + 2 files changed, 11 insertions(+) diff --git a/libmproxy/contentviews.py b/libmproxy/contentviews.py index 8d5aadfce..aa2082d1c 100644 --- a/libmproxy/contentviews.py +++ b/libmproxy/contentviews.py @@ -520,8 +520,18 @@ def add(obj): if i.name == obj.name: raise ContentViewException("Duplicate view: " + obj.name) + for prompt in view_prompts: + if prompt[1] == obj.prompt[1]: + raise ContentViewException("Duplicate view shortcut: " + obj.prompt[1]) + views.append(obj) + for ct in obj.content_types: + l = content_types_map.setdefault(ct, []) + l.append(obj) + + view_prompts.append(obj.prompt) + def get(name): for i in views: diff --git a/test/test_contentview.py b/test/test_contentview.py index 68272fca3..c1e437e49 100644 --- a/test/test_contentview.py +++ b/test/test_contentview.py @@ -217,6 +217,7 @@ Larry tcv = TestContentView() cv.add(tcv) + # repeated addition causes exception tutils.raises( ContentViewException, cv.add,