backport 3.5
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Mon, 14 Sep 2009 11:25:56 +0200
changeset 3199 fc63b80ec979
parent 3195 a6f1daddfe8a (current diff)
parent 3198 d2f48d30e73e (diff)
child 3230 1d25e928c299
backport 3.5
__pkginfo__.py
cwctl.py
etwist/server.py
server/migractions.py
server/session.py
web/views/editcontroller.py
--- a/.hgtags	Mon Sep 14 08:34:11 2009 +0200
+++ b/.hgtags	Mon Sep 14 11:25:56 2009 +0200
@@ -66,3 +66,5 @@
 ebb92e62eb040a070deb1f2d2434734cfac3af01 cubicweb-debian-version-3.4.7-1
 ba43e084e8841f62c3b4c2449b26a7546233e5fb cubicweb-version-3.4.8
 97273eeaaead11c0f422dc5a4fe2d4f14fc6a2dd cubicweb-debian-version-3.4.8-1
+e916f1e856c83aced0fe73f7ae9068e37edcc38c cubicweb-version-3.4.9
+24ea70f19a48cce60248ab18695925755009bcb8 cubicweb-debian-version-3.4.9-1
--- a/cwctl.py	Mon Sep 14 08:34:11 2009 +0200
+++ b/cwctl.py	Mon Sep 14 11:25:56 2009 +0200
@@ -659,7 +659,7 @@
             print '-> migration needed from %s to %s for %s' % (fromversion, toversion, cube)
         # only stop once we're sure we have something to do
         if not (cwcfg.mode == 'dev' or self.config.nostartstop):
-            StopCommand().stop_instance(appid)
+            StopInstanceCommand().stop_instance(appid)
         # run cubicweb/componants migration scripts
         mih.migrate(vcconf, reversed(toupgrade), self.config)
         # rewrite main configuration file
@@ -682,7 +682,7 @@
         print
         print '-> instance migrated.'
         if not (cwcfg.mode == 'dev' or self.config.nostartstop):
-            StartCommand().start_instance(appid)
+            StartInstanceCommand().start_instance(appid)
         print
 
 
--- a/debian/changelog	Mon Sep 14 08:34:11 2009 +0200
+++ b/debian/changelog	Mon Sep 14 11:25:56 2009 +0200
@@ -1,3 +1,9 @@
+cubicweb (3.4.10-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Sylvain Thénault <sylvain.thenault@logilab.fr>  Fri, 11 Sep 2009 17:19:37 +0200
+
 cubicweb (3.4.9-1) unstable; urgency=low
 
   * new upstream release
--- a/etwist/server.py	Mon Sep 14 08:34:11 2009 +0200
+++ b/etwist/server.py	Mon Sep 14 11:25:56 2009 +0200
@@ -29,17 +29,10 @@
 
 from cubicweb.etwist.request import CubicWebTwistedRequestAdapter
 
-def daemonize(uid):
+def daemonize():
     # XXX unix specific
     # XXX factorize w/ code in cw.server.server and cw.server.serverctl
     # (start-repository command)
-    if uid is not None:
-        try:
-            uid = int(uid)
-        except ValueError:
-            from pwd import getpwnam
-            uid = getpwnam(uid).pw_uid
-        os.setuid(uid)
     # See http://www.erlenstar.demon.co.uk/unix/faq_toc.html#TOC16
     if os.fork():   # launch child and...
         return -1
@@ -397,7 +390,7 @@
     logger = getLogger('cubicweb.twisted')
     logger.info('instance started on %s', baseurl)
     if not debug:
-        if daemonize(config['uid']):
+        if daemonize():
             # child process
             return
         if config['pid-file']:
@@ -407,6 +400,13 @@
             if not os.path.exists(piddir):
                 os.makedirs(piddir)
             file(config['pid-file'], 'w').write(str(os.getpid()))
+    if config['uid'] is not None:
+        try:
+            uid = int(config['uid'])
+        except ValueError:
+            from pwd import getpwnam
+            uid = getpwnam(config['uid']).pw_uid
+        os.setuid(uid)
     if config['profile']:
         prof = hotshot.Profile(config['profile'])
         prof.runcall(reactor.run)
--- a/server/migractions.py	Mon Sep 14 08:34:11 2009 +0200
+++ b/server/migractions.py	Mon Sep 14 11:25:56 2009 +0200
@@ -116,7 +116,7 @@
         config = self.config
         repo = self.repo_connect()
         # paths
-        timestamp = datetime.now().strftime('%Y-%m-%d_%H:%M:%S')
+        timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
         instbkdir = osp.join(config.appdatahome, 'backup')
         if not osp.exists(instbkdir):
             os.makedirs(instbkdir)
--- a/server/session.py	Mon Sep 14 08:34:11 2009 +0200
+++ b/server/session.py	Mon Sep 14 11:25:56 2009 +0200
@@ -81,13 +81,13 @@
         session._threaddata = self.actual_session()._threaddata
         return session
 
-    def _change_relation(self, cb, fromeid, rtype, toeid):
+    def _super_call(self, __cb, *args, **kwargs):
         if self.is_super_session:
-            cb(self, fromeid, rtype, toeid)
+            __cb(self, *args, **kwargs)
             return
         self.is_super_session = True
         try:
-            cb(self, fromeid, rtype, toeid)
+            __cb(self, *args, **kwargs)
         finally:
             self.is_super_session = False
 
@@ -102,8 +102,15 @@
         You may use this in hooks when you know both eids of the relation you
         want to add.
         """
-        self._change_relation(self.repo.glob_add_relation,
-                              fromeid, rtype, toeid)
+        if self.vreg.schema[rtype].inlined:
+            entity = self.entity_from_eid(fromeid)
+            entity[rtype] = toeid
+            self._super_call(self.repo.glob_update_entity,
+                             entity, set((rtype,)))
+        else:
+            self._super_call(self.repo.glob_add_relation,
+                             fromeid, rtype, toeid)
+
     def delete_relation(self, fromeid, rtype, toeid):
         """provide direct access to the repository method to delete a relation.
 
@@ -115,8 +122,14 @@
         You may use this in hooks when you know both eids of the relation you
         want to delete.
         """
-        self._change_relation(self.repo.glob_delete_relation,
-                              fromeid, rtype, toeid)
+        if self.vreg.schema[rtype].inlined:
+            entity = self.entity_from_eid(fromeid)
+            entity[rtype] = None
+            self._super_call(self.repo.glob_update_entity,
+                             entity, set((rtype,)))
+        else:
+            self._super_call(self.repo.glob_delete_relation,
+                             fromeid, rtype, toeid)
 
     # relations cache handling #################################################
 
@@ -149,8 +162,12 @@
             if not isinstance(rset.description, list): # else description not set
                 rset.description = list(rset.description)
             rset.description.append([self.describe(targeteid)[0]])
+            targetentity = self.entity_from_eid(targeteid)
+            if targetentity.rset is None:
+                targetentity.rset = rset
+                targetentity.row = rset.rowcount
+                targetentity.col = 0
             rset.rowcount += 1
-            targetentity = self.entity_from_eid(targeteid)
             entities.append(targetentity)
 
     def _update_entity_rel_cache_del(self, eid, rtype, role, targeteid):
--- a/web/views/editcontroller.py	Mon Sep 14 08:34:11 2009 +0200
+++ b/web/views/editcontroller.py	Mon Sep 14 11:25:56 2009 +0200
@@ -248,7 +248,7 @@
                 except ValueError:
                     raise ValidationError(entity.eid,
                                           {attr: self.req._("invalid float value")})
-            if attrtype in ('Date', 'Datetime', 'Time'):
+            elif attrtype in ('Date', 'Datetime', 'Time'):
                 try:
                     value = self.parse_datetime(value, attrtype)
                 except ValueError: