Commits

Zhang Huangbin  committed 4b22702

Code cleanup.

  • Participants
  • Parent commits 35afaae

Comments (0)

Files changed (2)

File libs/dbmail_mysql/user.py

                     except:
                         pass
 
+            vars_addition_sql = {'user_idnr': user_idnr,
+                                 'mail': self.mail,
+                                 'username': self.username,
+                                 'domain': self.domain,
+                                }
             # Execute addition SQL commands after successfully created new users.
             if settings.DBMAIL_SQL_FOR_NEWLY_CREATED_USER:
-                vars_addition_sql = {'user_idnr': user_idnr,
-                                     'mail': self.mail,
-                                     'username': self.username,
-                                     'domain': self.domain,
-                                    }
                 try:
                     for sql_cmd in settings.DBMAIL_SQL_FOR_NEWLY_CREATED_USER:
                         self.conn.query(sql_cmd, vars=vars_addition_sql)
 
             # Create Amavisd policy for newly created user.
             if settings.AMAVISD_EXECUTE_SQL_WITHOUT_ENABLED and settings.AMAVISD_SQL_FOR_NEWLY_CREATED_USER:
-                vars_amavisd = {
-                    'mail': self.mail,
-                    'username': web.sqlquote(self.username),
-                    'domain': web.sqlquote(self.domain),
-                }
                 try:
                     from libs.amavisd.core import AmavisdWrap
                     amwrap = AmavisdWrap()
                     for sql_cmd in settings.AMAVISD_SQL_FOR_NEWLY_CREATED_USER:
-                        amwrap.db.query(sql_cmd % vars_amavisd)
+                        amwrap.db.query(sql_cmd, vars=vars_addition_sql)
                 except:
                     pass
 

File libs/settings.py

 # - without timestamp: domain.ltd/username/
 MAILDIR_APPEND_TIMESTAMP = True
 
-# Execute addition SQL commands after successfully created new users.
-#
-# Available placeholders:
-#   - $user_idnr: value of dbmail_users.user_idnr
-#   - $mail:     replaced by email address of newly created user
-#   - $username: replaced by username part of email address
-#   - $domain:   replaced by domain part of email address
-#
-# For example:
-#
-#   DBMAIL_SQL_FOR_NEWLY_CREATED_USER = [
-#       """INSERT INTO dbmail_sievescripts (owner_idnr, name, script, active)
-#               VALUES (
-#                       $user_idnr,
-#                       'Move SPAM to Junk folder',
-#                       'require ["fileinto"]; if header :is "X-Spam-Flag" "YES" {fileinto "Junk"; stop;}',
-#                       1)
-#       """,
-#   ]
-#
-DBMAIL_SQL_FOR_NEWLY_CREATED_USER = []
-
-
 #######################################
 # OpenLDAP backend related settings.
 #
 # settings.ini.
 #
 # Available placeholders:
-#   - %(mail)s:     replaced by email address of newly created user
-#   - %(username)s: replaced by username part of email address
-#   - %(domain)s:   replaced by domain part of email address
+#   - $mail:     replaced by email address of newly created user
+#   - $username: replaced by username part of email address
+#   - $domain:   replaced by domain part of email address
 #
 # For example:
 #
 #   AMAVISD_SQL_FOR_NEWLY_CREATED_USER = [
-#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, %(mail)s)',
-#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, %(username)s)',
-#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, concat("@", %(domain)s))',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, $mail)',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, $username)',
+#       'INSERT INTO users (priority, policy_id, email) VALUES (0, 5, concat("@", $domain))',
 #   ]
 #
 # Will be replaced by:
 DBMAIL_CREATE_DEFAULT_IMAP_FOLDERS = True
 DBMAIL_DEFAULT_IMAP_FOLDERS = ['INBOX', 'Sent', 'Drafts', 'Trash', 'Junk', ]
 
+# Execute addition SQL commands after successfully created new users.
+#
+# Available placeholders:
+#   - $user_idnr: value of dbmail_users.user_idnr
+#   - $mail:     replaced by email address of newly created user
+#   - $username: replaced by username part of email address
+#   - $domain:   replaced by domain part of email address
+#
+# For example:
+#
+#   DBMAIL_SQL_FOR_NEWLY_CREATED_USER = [
+#       """INSERT INTO dbmail_sievescripts (owner_idnr, name, script, active)
+#               VALUES (
+#                       $user_idnr,
+#                       'Move SPAM to Junk folder',
+#                       'require ["fileinto"]; if header :is "X-Spam-Flag" "YES" {fileinto "Junk"; stop;}',
+#                       1)
+#       """,
+#   ]
+#
+DBMAIL_SQL_FOR_NEWLY_CREATED_USER = []
+
 ###################################
 # Minor settings. You do not need to change them.
 #