Important update of the plugin engine.

New plugin that allows the handling of an Amavisd-new SQL quarantine.

NB: a DB connections manager has been added inside the lib because
Django does not support multiple connections at the same time. The
main consequence is that we don't use an ORM and that we have to
rewrite a small wrapper that supports several DB (mysql, postgresql, etc.).
Adding a dependancy to an existing ORM module (like SQLalchemy) is
heavy, we don't want that for now.
This commit is contained in:
Antoine Nguyen
2009-06-26 17:13:35 +02:00
parent fc74d34c1d
commit fcab20b608
17 changed files with 227 additions and 19 deletions
+22
View File
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
"""
"""
connections = {}
def mysql_newconnection(host, dbname, login, password):
import MySQLdb
return MySQLdb.connect(host=host, db=dbname, user=login, passwd=password)
def getconnection(name):
if not name in connections.keys():
from django.conf import settings
cfg = settings.DB_CONNECTIONS[name]
if cfg["driver"] == "mysql":
conn = mysql_newconnection(cfg["host"], cfg["dbname"], cfg["login"],
cfg["password"])
connections[name] = conn
return connections[name]
+11 -1
View File
@@ -9,7 +9,9 @@ core application and additional components.
events = ["CreateDomain",
"DeleteDomain",
"CreateMailbox",
"DeleteMailbox"]
"DeleteMailbox",
"UserMenuDisplay"]
callbacks = {}
@@ -27,3 +29,11 @@ def raiseEvent(event, **kwargs):
for callback in callbacks[event]:
callback(**kwargs)
return 1
def raiseQueryEvent(event, **kwargs):
result = []
if not event in events or not event in callbacks.keys():
return result
for callback in callbacks[event]:
result += callback(**kwargs)
return result