diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a77daab..a404899 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,7 @@ Changelog a list) - Fixed: `Issue #59 `__ (Raise ForbiddenError when a 403 is encountered) (thanks to `Rick Harris `__) +- Fixed: `Issue #64 `__ (Make the Redmine class picklable) (thanks to `Rick Harris `__) 1.0.1 (2014-09-23) ++++++++++++++++++ diff --git a/redmine/__init__.py b/redmine/__init__.py index 0d6aa9f..ba5bb76 100644 --- a/redmine/__init__.py +++ b/redmine/__init__.py @@ -38,6 +38,9 @@ def __init__(self, url, **kwargs): def __getattr__(self, resource): """Returns either ResourceSet or Resource object depending on the method used on the ResourceManager""" + if resource.startswith('_'): + raise AttributeError + return ResourceManager(self, resource) def upload(self, filepath): diff --git a/tests/test_redmine.py b/tests/test_redmine.py index b509c5e..12a35ab 100644 --- a/tests/test_redmine.py +++ b/tests/test_redmine.py @@ -163,3 +163,12 @@ def test_auth(self): self.response.status_code = 200 self.response.json = json_response({'user': {'firstname': 'John', 'lastname': 'Smith', 'id': 1}}) self.assertEqual(self.redmine.auth().firstname, 'John') + + def test_getattr_on_under_attribute(self): + """ + Attributes that begin with an underscore should not be treated as a + `Resource`. The impetus of this was to make `Redmine` picklable by + preventing the `__getstate__` access from being treated a `Resource`. + """ + with self.assertRaises(AttributeError): + self.redmine.__getstate__