# HG changeset patch # User Nicolas Chauvat # Date 1302547410 -7200 # Node ID 2723c52a07956cfc41f9666a32e9b690818d5d43 # Parent 2e25b97c0bef69b0f77b8975b406aba98c787b6b# Parent 9220ae2cacf105f90174e3283379de6a72f5a708 merge changes from stable branch diff -r 2e25b97c0bef -r 2723c52a0795 cwvreg.py --- a/cwvreg.py Thu Apr 07 00:27:47 2011 +0200 +++ b/cwvreg.py Mon Apr 11 20:43:30 2011 +0200 @@ -1,4 +1,4 @@ -# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved. +# copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This file is part of CubicWeb. diff -r 2e25b97c0bef -r 2723c52a0795 dataimport.py --- a/dataimport.py Thu Apr 07 00:27:47 2011 +0200 +++ b/dataimport.py Mon Apr 11 20:43:30 2011 +0200 @@ -147,13 +147,16 @@ for row in reader: yield dict(zip(header, row)) -def lazydbtable(cu, table, headers): +def lazydbtable(cu, table, headers, orderby=None): """return an iterator on rows of a sql table. On each row, fetch columns defined in headers and return values as a dictionary. >>> data = lazydbtable(cu, 'experimentation', ('id', 'nickname', 'gps')) """ - cu.execute('SELECT %s FROM %s' % (','.join(headers), table,)) + sql = 'SELECT %s FROM %s' % (','.join(headers), table,) + if orderby: + sql += ' ORDER BY %s' % ','.join(orderby) + cu.execute(sql) while True: row = cu.fetchone() if row is None: diff -r 2e25b97c0bef -r 2723c52a0795 entity.py --- a/entity.py Thu Apr 07 00:27:47 2011 +0200 +++ b/entity.py Mon Apr 11 20:43:30 2011 +0200 @@ -263,8 +263,16 @@ relations = [] restrictions = set() pending_relations = [] + eschema = cls.e_schema for attr, value in kwargs.items(): - if isinstance(value, (tuple, list, set, frozenset)): + if attr.startswith('reverse_'): + attr = attr[len('reverse_'):] + role = 'object' + else: + role = 'subject' + assert eschema.has_relation(attr, role) + rschema = eschema.subjrels[attr] if role == 'subject' else eschema.objrels[attr] + if not rschema.final and isinstance(value, (tuple, list, set, frozenset)): if len(value) == 1: value = iter(value).next() else: diff -r 2e25b97c0bef -r 2723c52a0795 server/sources/native.py --- a/server/sources/native.py Thu Apr 07 00:27:47 2011 +0200 +++ b/server/sources/native.py Mon Apr 11 20:43:30 2011 +0200 @@ -282,7 +282,7 @@ self._temp_table_data = {} # we need a lock to protect eid attribution function (XXX, really? # explain) - self._eid_creation_lock = Lock() + self._eid_cnx_lock = Lock() self._eid_creation_cnx = None # (etype, attr) / storage mapping self._storages = {} @@ -835,27 +835,22 @@ self.doexec(session, sql) def _create_eid_sqlite(self, session): - self._eid_creation_lock.acquire() - try: + with self._eid_cnx_lock: for sql in self.dbhelper.sqls_increment_sequence('entities_id_seq'): cursor = self.doexec(session, sql) return cursor.fetchone()[0] - finally: - self._eid_creation_lock.release() def create_eid(self, session): - # lock needed to prevent 'Connection is busy with results for another command (0)' errors with SQLServer - self._eid_creation_lock.acquire() - try: + # lock needed to prevent 'Connection is busy with results for another + # command (0)' errors with SQLServer + with self._eid_cnx_lock: return self._create_eid() - finally: - self._eid_creation_lock.release() def _create_eid(self): # internal function doing the eid creation without locking. # needed for the recursive handling of disconnections (otherwise we - # deadlock on self._eid_creation_lock + # deadlock on self._eid_cnx_lock if self._eid_creation_cnx is None: self._eid_creation_cnx = self.get_connection() cnx = self._eid_creation_cnx diff -r 2e25b97c0bef -r 2723c52a0795 web/data/cubicweb.ajax.js --- a/web/data/cubicweb.ajax.js Thu Apr 07 00:27:47 2011 +0200 +++ b/web/data/cubicweb.ajax.js Mon Apr 11 20:43:30 2011 +0200 @@ -501,7 +501,7 @@ var fck = new FCKeditor(this.id); fck.Config['CustomConfigurationsPath'] = fckconfigpath; fck.Config['DefaultLanguage'] = fcklang; - fck.BasePath = "fckeditor/"; + fck.BasePath = baseuri() + "fckeditor/"; fck.ReplaceTextarea(); } else { cw.log('fckeditor could not be found.'); diff -r 2e25b97c0bef -r 2723c52a0795 web/facet.py --- a/web/facet.py Thu Apr 07 00:27:47 2011 +0200 +++ b/web/facet.py Mon Apr 11 20:43:30 2011 +0200 @@ -940,29 +940,37 @@ return None return self.wdgclass(self, min(values), max(values)) - def infvalue(self): - return self._cw.form.get('%s_inf' % self.__regid__) - - def supvalue(self): - return self._cw.form.get('%s_sup' % self.__regid__) - def formatvalue(self, value): """format `value` before in order to insert it in the RQL query""" return unicode(value) + def infvalue(self, min=False): + if min: + return self._cw.form.get('min_%s_inf' % self.__regid__) + return self._cw.form.get('%s_inf' % self.__regid__) + + def supvalue(self, max=False): + if max: + return self._cw.form.get('max_%s_sup' % self.__regid__) + return self._cw.form.get('%s_sup' % self.__regid__) + def add_rql_restrictions(self): infvalue = self.infvalue() - if infvalue is None: # nothing sent + supvalue = self.supvalue() + if infvalue is None or supvalue is None: # nothing sent return - supvalue = self.supvalue() - self.rqlst.add_constant_restriction(self.filtered_variable, - self.rtype, - self.formatvalue(infvalue), - self.attrtype, '>=') - self.rqlst.add_constant_restriction(self.filtered_variable, - self.rtype, - self.formatvalue(supvalue), - self.attrtype, '<=') + # when a value is equal to one of the limit, don't add the restriction, + # else we filter out NULL values implicitly + if infvalue != self.infvalue(min=True): + self.rqlst.add_constant_restriction(self.filtered_variable, + self.rtype, + self.formatvalue(infvalue), + self.attrtype, '>=') + if supvalue != self.supvalue(max=True): + self.rqlst.add_constant_restriction(self.filtered_variable, + self.rtype, + self.formatvalue(supvalue), + self.attrtype, '<=') class DateRangeFacet(RangeFacet): @@ -1138,6 +1146,10 @@ % (facetid, self.minvalue)) self.w(u'' % (facetid, self.maxvalue)) + self.w(u'' + % (facetid, self.minvalue)) + self.w(u'' + % (facetid, self.maxvalue)) self.w(u'
' % sliderid) self.w(u'\n')