backport stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Wed, 23 Sep 2009 08:17:52 +0200
changeset 3375 ebb11fa58ab9
parent 3373 3cd644bfab12 (current diff)
parent 3374 d5bd1b659ce8 (diff)
child 3376 f5c69485381f
backport stable
utils.py
--- a/common/mail.py	Tue Sep 22 19:33:47 2009 +0200
+++ b/common/mail.py	Wed Sep 23 08:17:52 2009 +0200
@@ -210,7 +210,13 @@
         """return a list of either 2-uple (email, language) or user entity to
         who this email should be sent
         """
-        finder = self.vreg['components'].select('recipients_finder', self.req,
+        # use super_session when available, we don't want to consider security
+        # when selecting recipients_finder
+        try:
+            req = self.req.super_session
+        except AttributeError:
+            req = self.req
+        finder = self.vreg['components'].select('recipients_finder', req,
                                                 rset=self.rset,
                                                 row=self.row or 0,
                                                 col=self.col or 0)
--- a/server/checkintegrity.py	Tue Sep 22 19:33:47 2009 +0200
+++ b/server/checkintegrity.py	Wed Sep 23 08:17:52 2009 +0200
@@ -211,8 +211,8 @@
                     if not has_eid(cursor, eid, eids):
                         bad_related_msg(rschema, 'object', eid, fix)
                         if fix:
-                            sql = 'UPDATE %s SET %s = NULL WHERE %seid=%s;' % (
-                                table, column, SQL_PREFIX, eid)
+                            sql = 'UPDATE %s SET %s=NULL WHERE %s=%s;' % (
+                                table, column, column, eid)
                             session.system_sql(sql)
             continue
         cursor = session.system_sql('SELECT eid_from FROM %s_relation;' % rschema)
--- a/utils.py	Tue Sep 22 19:33:47 2009 +0200
+++ b/utils.py	Wed Sep 23 08:17:52 2009 +0200
@@ -20,8 +20,6 @@
 from calendar import monthrange
 import decimal
 
-import simplejson
-
 # initialize random seed from current time
 seed()
 try:
@@ -364,24 +362,25 @@
     return True
 
 try:
-    # may not be there is cubicweb-web not there
-    from simplejson import JSONEncoder, dumps
+    # may not be there if cubicweb-web not installed
+    from simplejson import dumps, JSONEncoder
 except ImportError:
     pass
 else:
+
     class CubicWebJsonEncoder(JSONEncoder):
         """define a simplejson encoder to be able to encode yams std types"""
         def default(self, obj):
-            if isinstance(obj, datetime):
+            if isinstance(obj, pydatetime.datetime):
                 return obj.strftime('%Y/%m/%d %H:%M:%S')
-            elif isinstance(obj, date):
+            elif isinstance(obj, pydatetime.date):
                 return obj.strftime('%Y/%m/%d')
             elif isinstance(obj, pydatetime.time):
                 return obj.strftime('%H:%M:%S')
             elif isinstance(obj, decimal.Decimal):
                 return float(obj)
             try:
-                return simplejson.JSONEncoder.default(self, obj)
+                return JSONEncoder.default(self, obj)
             except TypeError:
                 # we never ever want to fail because of an unknown type,
                 # just return None in those cases.