backport stable 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Tue, 08 Sep 2009 16:00:14 +0200
branch3.5
changeset 3120 57ceabc6dfbc
parent 3119 819aea456251 (current diff)
parent 3114 f87fd632e3f6 (diff)
child 3121 dbc02844d412
backport stable
common/mail.py
server/migractions.py
server/session.py
server/test/unittest_querier.py
web/data/cubicweb.ajax.js
--- a/common/mail.py	Tue Sep 08 15:59:20 2009 +0200
+++ b/common/mail.py	Tue Sep 08 16:00:14 2009 +0200
@@ -256,5 +256,6 @@
                        'title': entity.dc_long_title(),})
         return kwargs
 
+
 class SkipEmail(Exception):
     """raise this if you decide to skip an email during its generation"""
--- a/server/migractions.py	Tue Sep 08 15:59:20 2009 +0200
+++ b/server/migractions.py	Tue Sep 08 16:00:14 2009 +0200
@@ -166,14 +166,20 @@
                                            % (self.config.appid, backupfile)):
             return
         # unpack backup
-        bkup = tarfile.open(backupfile, 'r|gz')
-        for name in bkup.getnames():
-            if name[0] in '/.':
-                raise Exception('Security check failed, path starts with "/" or "."')
-        bkup.close() # XXX seek error if not close+open !?!
-        bkup = tarfile.open(backupfile, 'r|gz')
         tmpdir = tempfile.mkdtemp()
-        bkup.extractall(path=tmpdir)
+        try:
+            bkup = tarfile.open(backupfile, 'r|gz')
+        except tarfile.ReadError:
+            # assume restoring old backup
+            shutil.copy(backupfile, osp.join(tmpdir, 'system'))  
+        else:
+            for name in bkup.getnames():
+                if name[0] in '/.':
+                    raise Exception('Security check failed, path starts with "/" or "."')
+            bkup.close() # XXX seek error if not close+open !?!
+            bkup = tarfile.open(backupfile, 'r|gz')
+            bkup.extractall(path=tmpdir)
+            bkup.close()
 
         self.config.open_connections_pools = False
         repo = self.repo_connect()
@@ -186,7 +192,6 @@
                 print '-> error trying to restore [%s]' % exc
                 if not self.confirm('Continue anyway?', default='n'):
                     raise SystemExit(1)
-        bkup.close()
         shutil.rmtree(tmpdir)
         # call hooks
         repo.open_connections_pools()
--- a/server/querier.py	Tue Sep 08 15:59:20 2009 +0200
+++ b/server/querier.py	Tue Sep 08 16:00:14 2009 +0200
@@ -608,6 +608,8 @@
                     # return an empty result instead of raising UnknownEid
                     return empty_rset(session, rql, args)
                 cachekey.append(etype)
+                # ensure eid is correctly typed in args
+                args[key] = typed_eid(args[key])
             cachekey = tuple(cachekey)
         else:
             cachekey = rql
--- a/server/test/unittest_querier.py	Tue Sep 08 15:59:20 2009 +0200
+++ b/server/test/unittest_querier.py	Tue Sep 08 16:00:14 2009 +0200
@@ -213,6 +213,11 @@
         # should return an empty result set
         self.failIf(self.execute('Any X WHERE X eid 99999999'))
 
+    def test_typed_eid(self):
+        # should return an empty result set
+        rset = self.execute('Any X WHERE X eid %(x)s', {'x': '1'}, 'x')
+        self.assertIsInstance(rset[0][0], (int, long))
+
     def test_bytes_storage(self):
         feid = self.execute('INSERT File X: X name "foo.pdf", X data_format "text/plain", X data %(data)s',
                             {'data': Binary("xxx")})[0][0]
--- a/web/data/cubicweb.ajax.js	Tue Sep 08 15:59:20 2009 +0200
+++ b/web/data/cubicweb.ajax.js	Tue Sep 08 16:00:14 2009 +0200
@@ -392,7 +392,9 @@
     return stripped;
 }
 
-/* convenience function that returns a DOM node based on req's result. */
+/* convenience function that returns a DOM node based on req's result.
+ * XXX clarify the need to clone
+ * */
 function getDomFromResponse(response) {
     if (typeof(response) == 'string') {
 	var doc = html2dom(response);
--- a/web/data/cubicweb.facets.js	Tue Sep 08 15:59:20 2009 +0200
+++ b/web/data/cubicweb.facets.js	Tue Sep 08 16:00:14 2009 +0200
@@ -130,9 +130,10 @@
 		});
 		facet.find('div.facetCheckBox').click(function () {
 		    var $this = jQuery(this);
-		    if ($this.hasClass('facetValueDisabled')){
-		     	    return
-		    }
+		    // NOTE : add test on the facet operator (i.e. OR, AND)
+		    // if ($this.hasClass('facetValueDisabled')){
+		    //  	    return
+		    // }
 		    if ($this.hasClass('facetValueSelected')) {
 			$this.removeClass('facetValueSelected');
 			$this.find('img').each(function (i){
--- a/web/formwidgets.py	Tue Sep 08 15:59:20 2009 +0200
+++ b/web/formwidgets.py	Tue Sep 08 16:00:14 2009 +0200
@@ -430,8 +430,9 @@
         # XXX entity form specific
         entity = form.edited_entity
         attrs['cubicweb:etype_to'] = entity.e_schema
-        etype_from = entity.e_schema.subject_relation(self.name).objects(entity.e_schema)[0]
+        etype_from = entity.e_schema.subject_relation(field.name).objects(entity.e_schema)[0]
         attrs['cubicweb:etype_from'] = etype_from
+        return name, values, attrs
 
     def render(self, form, field, renderer):
         return super(AddComboBoxWidget, self).render(form, field, renderer) + u'''