Projects
Kolab:3.4
pykolab
pykolab-0.6.11-unlink-cache-on-failure-to-get_e...
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File pykolab-0.6.11-unlink-cache-on-failure-to-get_entry.patch of Package pykolab (Revision 63)
Currently displaying revision
63
,
Show latest
diff --git a/pykolab/auth/ldap/cache.py b/pykolab/auth/ldap/cache.py index 55a47c3..ad50e9b 100644 --- a/pykolab/auth/ldap/cache.py +++ b/pykolab/auth/ldap/cache.py @@ -107,8 +107,17 @@ def delete_entry(domain, entry): def get_entry(domain, entry, update=True): result_attribute = conf.get('cyrus-sasl', 'result_attribute') + _entry = None + db = init_db(domain) - _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() + try: + _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() + except sqlalchemy.exc.OperationalError, errmsg: + db = init_db(domain,reinit=True) + except sqlalchemy.exc.InvalidRequestError, errmsg: + db = init_db(domain,reinit=True) + finally: + _entry = db.query(Entry).filter_by(uniqueid=entry['id']).first() if not update: return _entry @@ -149,15 +158,20 @@ def get_entry(domain, entry, update=True): return _entry -def init_db(domain): +def init_db(domain,reinit=False): """ Returns a SQLAlchemy Session() instance. """ global db - if not db == None: + if not db == None and not reinit: return db + if reinit: + import os + if os.path.isfile('sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain)): + os.unlink('sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain)) + db_uri = 'sqlite:///%s/%s.db' % (KOLAB_LIB_PATH, domain) echo = conf.debuglevel > 8 engine = create_engine(db_uri, echo=echo)
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.