--- 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.
--- 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:
--- 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:
--- 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
--- 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.');
--- 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'<input type="hidden" name="%s_sup" value="%s" />'
% (facetid, self.maxvalue))
+ self.w(u'<input type="hidden" name="min_%s_inf" value="%s" />'
+ % (facetid, self.minvalue))
+ self.w(u'<input type="hidden" name="max_%s_sup" value="%s" />'
+ % (facetid, self.maxvalue))
self.w(u'<div id="%s"></div>' % sliderid)
self.w(u'</div>\n')