Issue: Attribute Error during exception handling
Author: conqp
State: closed
Created: 2015-09-01 07:08:05

Hi, this is probably a bug:

```
Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/PyMySQL-0.6.3-py3.4.egg/pymysql/connections.py", line 823, in _connect
(self.host, self.port), self.connect_timeout)
File "/usr/lib/python3.4/socket.py", line 491, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "/usr/lib/python3.4/socket.py", line 530, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homeinfo/peewee/__init__.py", line 36, in execute_sql
return super().execute_sql(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3442, in execute_sql
with self.execution_context():
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3916, in __enter__
**self.database.connect_kwargs)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3841, in _connect
return mysql.connect(db=database, **conn_kwargs)
File "/usr/local/lib/python3.4/dist-packages/PyMySQL-0.6.3-py3.4.egg/pymysql/__init__.py", line 88, in Connect
return Connection(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/PyMySQL-0.6.3-py3.4.egg/pymysql/connections.py", line 647, in __init__
self._connect()
File "/usr/local/lib/python3.4/dist-packages/PyMySQL-0.6.3-py3.4.egg/pymysql/connections.py", line 862, in _connect
"Can't connect to MySQL server on %r (%s)" % (self.host, e))
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'alt.homeinfo.de' ([Errno -2] Name or service not known)")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/homie/retard.py", line 258, in _export
exporter.openimmo = data
File "/usr/local/lib/python3.4/dist-packages/homie/api/interface.py", line 403, in openimmo
for delete_id in delete_ids:
File "/usr/local/lib/python3.4/dist-packages/homie/api/interface.py", line 350, in _extr_idents
for real_estate in real_estates:
File "/usr/local/lib/python3.4/dist-packages/homie/mods/openimmodb/interface.py", line 93, in _retrieve
for record in self._related_records(immobilie.openimmo_obid):
File "/usr/local/lib/python3.4/dist-packages/homie/mods/openimmodb/interface.py", line 122, in _related_records
yield from model.select().where(model.openimmo_obid == ident)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 2944, in __iter__
return iter(self.execute())
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 2937, in execute
self._qr = ResultWrapper(model_class, self._execute(), query_meta)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 2631, in _execute
return self.database.execute_sql(sql, params, self.require_commit)
File "/usr/local/lib/python3.4/dist-packages/homeinfo/peewee/__init__.py", line 36, in execute_sql
return super().execute_sql(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3928, in __exit__
self.txn.__exit__(exc_type, exc_val, exc_tb)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3995, in __exit__
self.rollback(False)
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3980, in rollback
self.db.rollback()
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3456, in rollback
self.get_conn().rollback()
File "/usr/local/lib/python3.4/dist-packages/peewee-2.6.3-py3.4-linux-x86_64.egg/peewee.py", line 3384, in get_conn
return self.__local.context_stack[-1].connection
AttributeError: 'ExecutionContext' object has no attribute 'connection'
```
- peewee version: a646d3e4608c866a8442e4f7b0c5694587bba9d4
- PyMySQL version: 7fec4a21efb43cec5f3ae6af11ca7eff373e44be


Thank you, this should be fixed.