Browse Source

manager does not need to be context manager

master
Edoardo Putti 8 years ago
parent
commit
a9882fa1a8
1 changed files with 1 additions and 20 deletions
  1. +1
    -20
      manager.py

+ 1
- 20
manager.py View File

@ -30,30 +30,11 @@ class CAManager(object):
def __init__(self, path): def __init__(self, path):
self.path = path self.path = path
self.ca = CALookup() self.ca = CALookup()
self.request = RequestLookup() self.request = RequestLookup()
self.certificate = CertificateLookup() self.certificate = CertificateLookup()
def __enter__(self):
"""
Enter a context block, connect to database
"""
self.conn = sqlite3.connect(self.db_path)
self.ca.conn = self.conn
return self
def __exit__(self, exc_type, exc_value, traceback):
"""
Exit a context block, disconnect from database
"""
if exc_type is not None:
print(exc_type, exc_value)
print(traceback)
self.ca.conn = None
self.conn.close()
@property @property
def db_path(self): def db_path(self):
return os.path.join(self.path, 'ca_manager.db') return os.path.join(self.path, 'ca_manager.db')


Loading…
Cancel
Save