merge back to stable some changes made on site for a customer.
--- a/etwist/service.py Fri May 28 08:05:17 2010 +0200
+++ b/etwist/service.py Sat May 29 10:18:02 2010 +0200
@@ -71,6 +71,8 @@
_check_env(os.environ)
# create the site
config = cwcfg.config_for(self.instance)
+ config.init_log(force=True)
+ logger.info('starting cubicweb instance %s ', self.instance)
root_resource = CubicWebRootResource(config, False)
website = server.Site(root_resource)
# serve it via standard HTTP on port set in the configuration
--- a/server/repository.py Fri May 28 08:05:17 2010 +0200
+++ b/server/repository.py Sat May 29 10:18:02 2010 +0200
@@ -429,6 +429,7 @@
results['nb_active_threads'] = threading.activeCount()
results['looping_tasks'] = ', '.join(str(t) for t in self._looping_tasks)
results['available_pools'] = self._available_pools.qsize()
+ results['threads'] = ', '.join(sorted(str(t) for t in threading.enumerate()))
return results
def get_schema(self):
--- a/server/sources/ldapuser.py Fri May 28 08:05:17 2010 +0200
+++ b/server/sources/ldapuser.py Sat May 29 10:18:02 2010 +0200
@@ -201,6 +201,7 @@
def init(self):
"""method called by the repository once ready to handle request"""
+ self.info('ldap init')
self.repo.looping_task(self._interval, self.synchronize)
self.repo.looping_task(self._query_cache.ttl.seconds/10,
self._query_cache.clear_expired)
@@ -221,8 +222,10 @@
"source='%s'" % self.uri)
for eid, b64extid in cursor.fetchall():
extid = b64decode(b64extid)
+ self.debug('ldap eid %s', eid)
# if no result found, _search automatically delete entity information
res = self._search(session, extid, BASE)
+ self.debug('ldap search %s', res)
if res:
ldapemailaddr = res[0].get(ldap_emailattr)
if ldapemailaddr:
@@ -269,6 +272,7 @@
two queries are needed since passwords are stored crypted, so we have
to fetch the salt first
"""
+ self.info('ldap authenticate %s', login)
if password is None:
raise AuthenticationError()
searchfilter = [filter_format('(%s=%s)', (self.user_login_attr, login))]
@@ -343,6 +347,7 @@
possible type). If cachekey is given, the query necessary to fetch the
results (but not the results themselves) may be cached using this key.
"""
+ self.debug('ldap syntax tree search')
# XXX not handled : transform/aggregat function, join on multiple users...
assert len(union.children) == 1, 'union not supported'
rqlst = union.children[0]
@@ -494,19 +499,21 @@
def _search(self, session, base, scope,
searchstr='(objectClass=*)', attrs=()):
"""make an ldap query"""
+ self.info('ldap search %s %s %s %s %s', self.uri, base, scope, searchstr, list(attrs))
cnx = session.pool.connection(self.uri).cnx
try:
res = cnx.search_s(base, scope, searchstr, attrs)
except ldap.PARTIAL_RESULTS:
res = cnx.result(all=0)[1]
except ldap.NO_SUCH_OBJECT:
+ self.info('ldap NO SUCH OBJECT')
eid = self.extid2eid(base, 'CWUser', session, insert=False)
if eid:
self.warning('deleting ldap user with eid %s and dn %s',
eid, base)
entity = session.entity_from_eid(eid, 'CWUser')
self.repo.delete_info(session, entity, self.uri, base)
- self._cache.pop(base, None)
+ self.reset_cache()
return []
## except ldap.REFERRAL, e:
## cnx = self.handle_referral(e)
@@ -541,6 +548,7 @@
self._cache[rec_dn] = rec_dict
result.append(rec_dict)
#print '--->', result
+ self.info('ldap built results %s', result)
return result
def before_entity_insertion(self, session, lid, etype, eid):
@@ -551,6 +559,7 @@
This method must return the an Entity instance representation of this
entity.
"""
+ self.info('ldap before entity insertion')
entity = super(LDAPUserSource, self).before_entity_insertion(session, lid, etype, eid)
res = self._search(session, lid, BASE)[0]
for attr in entity.e_schema.indexable_attributes():
@@ -561,6 +570,7 @@
"""called by the repository after an entity stored here has been
inserted in the system table.
"""
+ self.info('ldap after entity insertion')
super(LDAPUserSource, self).after_entity_insertion(session, dn, entity)
for group in self.user_default_groups:
session.execute('SET X in_group G WHERE X eid %(x)s, G name %(group)s',
--- a/server/sources/native.py Fri May 28 08:05:17 2010 +0200
+++ b/server/sources/native.py Sat May 29 10:18:02 2010 +0200
@@ -444,6 +444,15 @@
self.warning("trying to reconnect")
session.pool.reconnect(self)
cursor = self.doexec(session, sql, args)
+ except (self.DbapiError,), exc:
+ # We get this one with pyodbc and SQL Server when connection was reset
+ if exc.args[0] == '08S01':
+ self.warning("trying to reconnect")
+ session.pool.reconnect(self)
+ cursor = self.doexec(session, sql, args)
+ else:
+ raise
+
results = self.process_result(cursor, cbs)
assert dbg_results(results)
return results
--- a/server/sqlutils.py Fri May 28 08:05:17 2010 +0200
+++ b/server/sqlutils.py Sat May 29 10:18:02 2010 +0200
@@ -165,6 +165,7 @@
dbapi_module = self.dbhelper.dbapi_module
self.OperationalError = dbapi_module.OperationalError
self.InterfaceError = dbapi_module.InterfaceError
+ self.DbapiError = dbapi_module.Error
self._binary = dbapi_module.Binary
self._process_value = dbapi_module.process_value
self._dbencoding = dbencoding
--- a/server/utils.py Fri May 28 08:05:17 2010 +0200
+++ b/server/utils.py Sat May 29 10:18:02 2010 +0200
@@ -123,6 +123,10 @@
class LoopTask(object):
"""threaded task restarting itself once executed"""
def __init__(self, interval, func, args):
+ if interval <= 0:
+ raise ValueError('Loop task interval must be > 0 '
+ '(current value: %f for %s)' % \
+ (interval, func.__name__))
self.interval = interval
def auto_restart_func(self=self, func=func, args=args):
try:
@@ -137,6 +141,7 @@
def start(self):
self._t = Timer(self.interval, self.func)
+ self._t.setName('%s-%s[%d]' % (self._t.getName(), self.name, self.interval))
self._t.start()
def cancel(self):