{"action":"created","issue":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/55","labels_url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/55/labels{/name}","comments_url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/55/comments","events_url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/55/events","html_url":"https://github.com/elasticsearch/elasticsearch-dsl-py/issues/55","id":54469790,"number":55,"title":"Inner exceptions on @property DocType","user":{"login":"dourvaris","id":248802,"avatar_url":"https://avatars.githubusercontent.com/u/248802?v=3","gravatar_id":"","url":"https://api.github.com/users/dourvaris","html_url":"https://github.com/dourvaris","followers_url":"https://api.github.com/users/dourvaris/followers","following_url":"https://api.github.com/users/dourvaris/following{/other_user}","gists_url":"https://api.github.com/users/dourvaris/gists{/gist_id}","starred_url":"https://api.github.com/users/dourvaris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dourvaris/subscriptions","organizations_url":"https://api.github.com/users/dourvaris/orgs","repos_url":"https://api.github.com/users/dourvaris/repos","events_url":"https://api.github.com/users/dourvaris/events{/privacy}","received_events_url":"https://api.github.com/users/dourvaris/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-15T16:26:50Z","updated_at":"2015-01-17T01:05:36Z","closed_at":"2015-01-16T18:05:46Z","body":"Using a property on classes makes debugging a nightmare, for example:\r\n  \r\n```python\r\nfrom elasticsearch_dsl import DocType, Search\r\nclass Foo(DocType):\r\n    @property\r\n    def bars(self):\r\n        return Search().eecute() # with a filter in reality\r\n\r\nfoo = Foo()\r\nfoo.bars\r\n```\r\nThis will raise **AttributeError: 'Foo' object has no attribute 'bars'**\r\n\r\nThe actual exception is **KeyError: \"There is no connection with alias 'default'.\"**\r\n```\r\n  File /elasticsearch-dsl/elasticsearch_dsl/search.py\", line 366, in execute\r\n    es = connections.get_connection(self._using)\r\n  File \"/elasticsearch-dsl/elasticsearch_dsl/connections.py\", line 53, in get_connection\r\n    raise KeyError('There is no connection with alias %r.' % alias)\r\n```\r\n\r\nI think the except AttributeError clauses in AttrDict and ObjectBase should be removed, I don't see how they add anything."},"comment":{"url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/comments/70347042","html_url":"https://github.com/elasticsearch/elasticsearch-dsl-py/issues/55#issuecomment-70347042","issue_url":"https://api.github.com/repos/elasticsearch/elasticsearch-dsl-py/issues/55","id":70347042,"user":{"login":"HonzaKral","id":32132,"avatar_url":"https://avatars.githubusercontent.com/u/32132?v=3","gravatar_id":"","url":"https://api.github.com/users/HonzaKral","html_url":"https://github.com/HonzaKral","followers_url":"https://api.github.com/users/HonzaKral/followers","following_url":"https://api.github.com/users/HonzaKral/following{/other_user}","gists_url":"https://api.github.com/users/HonzaKral/gists{/gist_id}","starred_url":"https://api.github.com/users/HonzaKral/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HonzaKral/subscriptions","organizations_url":"https://api.github.com/users/HonzaKral/orgs","repos_url":"https://api.github.com/users/HonzaKral/repos","events_url":"https://api.github.com/users/HonzaKral/events{/privacy}","received_events_url":"https://api.github.com/users/HonzaKral/received_events","type":"User","site_admin":false},"created_at":"2015-01-17T01:05:36Z","updated_at":"2015-01-17T01:05:36Z","body":"Just to be clear, `ObjectBase` does not try/except it away - it's python's `object` class that does this in it's `__getattribute__` - when a class has `__getattr__` defined, this is the behavior:\r\n\r\n    class A(object):\r\n        @property\r\n        def f(self):\r\n            return self.g\r\n\r\n        def __getattr__(self, name):\r\n            raise AttributeError(name + '!!!')\r\n\r\n    print(A().f)\r\n\r\nit is standard python behavior and that's why I am reluctant to \"fix\" it. The fix would also contain modifying the object's `__getattribute__` instead of `__getattr__` which is potentially dangerous and can have some performance implications. I will run some tests and see what the difference would be if it's worth it."}}