merge stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 25 Aug 2010 11:22:47 +0200
branchstable
changeset 6143 d7d2edf70011
parent 6137 b33d32f28885 (diff)
parent 6138 65f5e488f983 (current diff)
child 6144 40af8e328e64
merge
cwconfig.py
--- a/cwconfig.py	Wed Aug 25 09:42:55 2010 +0200
+++ b/cwconfig.py	Wed Aug 25 11:22:47 2010 +0200
@@ -998,7 +998,7 @@
         """check given directory path exists, belongs to the user running the
         server process and is writeable.
 
-        If not, try to fix this, leting exception propagate when not possible.
+        If not, try to fix this, letting exception propagate when not possible.
         """
         if not exists(path):
             os.makedirs(path)
@@ -1009,7 +1009,10 @@
                 from pwd import getpwnam
                 uid = getpwnam(self['uid']).pw_uid
         else:
-            uid = os.getuid()
+            try:
+                uid = os.getuid()
+            except AttributeError: # we are on windows
+                return
         fstat = os.stat(path)
         if fstat.st_uid != uid:
             os.chown(path, uid, os.getgid())
--- a/dataimport.py	Wed Aug 25 09:42:55 2010 +0200
+++ b/dataimport.py	Wed Aug 25 11:22:47 2010 +0200
@@ -34,7 +34,7 @@
            ]
 
   def gen_users(ctl):
-      for row in ctl.get_data('utilisateurs'):
+      for row in ctl.iter_and_commit('utilisateurs'):
           entity = mk_entity(row, USERS)
           entity['upassword'] = u'motdepasse'
           ctl.check('login', entity['login'], None)
@@ -124,13 +124,15 @@
     for row in it:
         yield [item.decode(encoding) for item in row]
 
-def commit_every(nbit, store, it):
-    for i, x in enumerate(it):
-        yield x
-        if nbit is not None and i % nbit:
-            store.commit()
-    if nbit is not None:
-        store.commit()
+def callfunc_every(func, number, iterable):
+    """yield items of `iterable` one by one and call function `func`
+    every `number` iterations. Always call function `func` at the end.
+    """
+    for idx, item in enumerate(iterable):
+        yield item
+        if idx % number:
+            func()
+    func()
 
 def lazytable(reader):
     """The first row is taken to be the header of the table and
@@ -229,7 +231,7 @@
     return None
 
 def required(value):
-    """raise ValueError is value is empty
+    """raise ValueError if value is empty
 
     This check should be often found in last position in the chain.
     """
@@ -570,7 +572,10 @@
 
     def iter_and_commit(self, datakey):
         """iter rows, triggering commit every self.commitevery iterations"""
-        return commit_every(self.commitevery, self.store, self.get_data(datakey))
+        if self.commitevery is None:
+            return self.get_data(datakey)
+        else:
+            return callfunc_every(self.commitevery, self.store.commit, self.get_data(datakey))
 
 
 
--- a/utils.py	Wed Aug 25 09:42:55 2010 +0200
+++ b/utils.py	Wed Aug 25 11:22:47 2010 +0200
@@ -334,7 +334,7 @@
     json_dumps = None
 
 else:
-
+    from logilab.common.date import ustrftime
     class CubicWebJsonEncoder(json.JSONEncoder):
         """define a json encoder to be able to encode yams std types"""
 
@@ -344,9 +344,9 @@
                 d['eid'] = obj.eid
                 return d
             if isinstance(obj, datetime.datetime):
-                return obj.strftime('%Y/%m/%d %H:%M:%S')
+                return ustrftime(obj, '%Y/%m/%d %H:%M:%S')
             elif isinstance(obj, datetime.date):
-                return obj.strftime('%Y/%m/%d')
+                return ustrftime(obj, '%Y/%m/%d')
             elif isinstance(obj, datetime.time):
                 return obj.strftime('%H:%M:%S')
             elif isinstance(obj, datetime.timedelta):
--- a/web/data/cubicweb.css	Wed Aug 25 09:42:55 2010 +0200
+++ b/web/data/cubicweb.css	Wed Aug 25 11:22:47 2010 +0200
@@ -537,6 +537,7 @@
   float: right;
   padding-left: 24px;
   position: relative;
+  z-index: 10;
 }
 div.toolbarButton {
   display: inline;