merge with stable fix
authorPierre-Yves David <pierre-yves.david@logilab.fr>
Tue, 02 Apr 2013 18:15:24 +0200
changeset 8848 08bb2dd18fd2
parent 8847 074f9f385f6b (current diff)
parent 8839 49eb84b80b96 (diff)
child 8849 7da8339cd768
merge with stable fix
server/repository.py
server/session.py
web/views/editcontroller.py
--- a/server/repository.py	Tue Apr 02 16:06:22 2013 +0200
+++ b/server/repository.py	Tue Apr 02 18:15:24 2013 +0200
@@ -882,19 +882,24 @@
         See :class:`cubicweb.dbapi.Connection.call_service`
         and :class:`cubicweb.server.Service`
         """
-        def task():
-            session = self._get_session(sessionid, setcnxset=True)
-            service = session.vreg['services'].select(regid, session, **kwargs)
-            try:
-                return service.call(**kwargs)
-            finally:
-                session.rollback() # free cnxset
+        session = self._get_session(sessionid)
+        return self._call_service_with_session(session, regid, async, **kwargs)
+
+    def _call_service_with_session(self, session, regid, async, **kwargs):
         if async:
             self.info('calling service %s asynchronously', regid)
+            def task():
+                session.set_cnxset()
+                try:
+                    service = session.vreg['services'].select(regid, session, **kwargs)
+                    return service.call(**kwargs)
+                finally:
+                    session.rollback() # free cnxset
             self.threaded_task(task)
         else:
             self.info('calling service %s synchronously', regid)
-            return task()
+            service = session.vreg['services'].select(regid, session, **kwargs)
+            return service.call(**kwargs)
 
     def user_info(self, sessionid, props=None):
         """this method should be used by client to:
--- a/server/session.py	Tue Apr 02 16:06:22 2013 +0200
+++ b/server/session.py	Tue Apr 02 18:15:24 2013 +0200
@@ -1142,7 +1142,8 @@
     # server-side service call #################################################
 
     def call_service(self, regid, async=False, **kwargs):
-        return self.repo.call_service(self.id, regid, async, **kwargs)
+        return self.repo._call_service_with_session(self, regid, async,
+                                                    **kwargs)
 
 
     # request interface #######################################################
--- a/web/data/cubicweb.css	Tue Apr 02 16:06:22 2013 +0200
+++ b/web/data/cubicweb.css	Tue Apr 02 18:15:24 2013 +0200
@@ -1085,3 +1085,21 @@
   margin-left: 0.5em;
   vertical-align: bottom;
 }
+
+/* cubicweb.views.undohistory uses :
+ *   - span.undo around undo link
+ *   - ul.undo-transactions to list transaction
+ *   - ol.undo-actions to list actions in a transaction
+ */
+
+span.undo {
+  border: 1pt;
+}
+
+ol.undo-actions > li {
+  margin-left: 2em;
+  margin-top: 2px;
+  padding: 0px 0px 2px 0px;
+  background-image: none;
+}
+
--- a/web/data/cubicweb.old.css	Tue Apr 02 16:06:22 2013 +0200
+++ b/web/data/cubicweb.old.css	Tue Apr 02 18:15:24 2013 +0200
@@ -116,7 +116,7 @@
   list-style-type: none;
 }
 
-ul li {
+ul > li {
   margin-top: 2px;
   padding: 0px 0px 2px 8px;
   background: url("bullet_orange.png") 0% 6px no-repeat;
@@ -1077,3 +1077,21 @@
   padding-left:0.5em;
   color:inherit;
 }
+
+/* cubicweb.views.undohistory uses :
+ *   - span.undo around undo link
+ *   - ul.undo-transactions to list transaction
+ *   - ol.undo-actions to list actions in a transaction
+ */
+
+span.undo {
+  border: 1pt;
+}
+
+ol.undo-actions > li {
+  margin-left: 2em;
+  margin-top: 2px;
+  padding: 0px 0px 2px 0px;
+  background-image: none;
+}
+
--- a/web/views/editcontroller.py	Tue Apr 02 16:06:22 2013 +0200
+++ b/web/views/editcontroller.py	Tue Apr 02 18:15:24 2013 +0200
@@ -77,6 +77,10 @@
         self.restrictions = []
         self.kwargs = {}
 
+    def __repr__(self):
+        return ('Query <edited=%r restrictions=%r kwargs=%r>' % (
+            self.edited, self.restrictions, self.kwargs))
+
     def insert_query(self, etype):
         if self.edited:
             rql = 'INSERT %s X: %s' % (etype, ','.join(self.edited))