Skip to content

Commit

Permalink
Fixed recursion error when
Browse files Browse the repository at this point in the history
disqus.interface.update(dict)

is used. Now throws InterfaceNotDefined expection.

disqus.update_interface(dict)

must be used now.
  • Loading branch information
Derrick Petzold committed Aug 29, 2014
1 parent 72183fa commit ede6a9f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
6 changes: 6 additions & 0 deletions disqusapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ def __init__(self, api, interfaces=INTERFACES, node=None, tree=()):
if node:
tree = tree + (node,)
self.tree = tree
self.interfaces_by_method = {}

def update_interface(self, interface):
raise NotImplemented

def __getattr__(self, attr):
if attr in getattr(self, '__dict__'):
return getattr(self, attr)
if attr == 'interface':
raise InterfaceNotDefined('You must use ``update_interface`` now.')
interface = {}
try:
interface = self.interfaces[attr]
Expand Down
24 changes: 24 additions & 0 deletions disqusapi/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
import disqusapi
from disqusapi.compat import xrange

extra_interface = {
"reserved": {
"global": {
"word": {
"method": "GET",
"required": [
"text",
],
"formats": [
"json",
],
}
}
}
}


def requires(*env_vars):
def wrapped(func):
Expand Down Expand Up @@ -120,6 +136,14 @@ def test_endpoint(self):

self.assertEquals(len(response1), len(response2))

def test_update_interface_legacy(self):
api = disqusapi.DisqusAPI(self.API_SECRET, self.API_PUBLIC)
with self.assertRaises(disqusapi.InterfaceNotDefined):
api.interface.update(extra_interface)

def test_update_interface(self):
api = disqusapi.DisqusAPI(self.API_SECRET, self.API_PUBLIC)
api.update_interface(extra_interface)

if __name__ == '__main__':
unittest.main()

0 comments on commit ede6a9f

Please sign in to comment.