This is not finished yet. More work than what I expected but the main part is done.
It will need a lot of testing... There is still a bug when activating a new extension
in development mode (ie. with python web server), I think it does not occur behind
a real web server.
This commit is contained in:
tonio
2010-05-04 17:25:23 +02:00
parent af8c33e659
commit 7480e479e7
15 changed files with 171 additions and 52 deletions
+17 -11
View File
@@ -2,29 +2,29 @@
import os
import re
extensions = []
extensions = {}
def loadextensions():
from django.conf import settings
from admin.models import Extension
expr = re.compile("mailng\.extensions\.(.+)")
for app in settings.INSTALLED_APPS:
m = expr.match(app)
if not m:
continue
module = __import__(m.group(1), globals(), locals(), ['main'])
exts = Extension.objects.filter(enabled=True)
for ext in exts:
module = __import__(ext.name, globals(), locals(), ['main'])
module.main.init()
globals()['extensions'] += [module]
globals()['extensions'][ext] = module
def loadmenus():
result = []
for mod in extensions:
for name, mod in extensions.iteritems():
u = mod.main.urls()
if u == ():
continue
result += (u,)
return result
def isenabled(ext):
return extensions.has_key(ext)
def list_extensions():
basedir = "extensions"
result = []
@@ -39,7 +39,13 @@ def list_extensions():
if isvalid:
module = __import__(d, globals(), locals(), ['main'])
try:
result += [module.main.infos()]
infos = module.main.infos()
infos["id"] = d
if os.path.isdir("%s/%s/templates" % (basedir, d)):
infos["templates"] = True
else:
infos["templates"] = False
result += [infos]
except AttributeError:
pass
return result
+4
View File
@@ -46,6 +46,10 @@ def init():
"/var/amavis/amavisd.sock",
help="")
def destroy():
events.unregister("UserMenuDisplay", menu)
parameters.unregister_app("amavis_quarantine")
def urls():
return (r'^mailng/quarantine/',
include('mailng.extensions.amavis_quarantine.urls'))
+3
View File
@@ -41,6 +41,9 @@ def init():
parameters.register("stats", "IMG_ROOTDIR", "string", "/tmp/mailng",
help=_("Path to directory where PNG files are stored"))
def destroy():
events.unregister("AdminMenuDisplay", menu)
def urls():
return (r'^mailng/stats/',
include('mailng.extensions.stats.urls'))
-1
View File
@@ -16,7 +16,6 @@ from mailng.lib import tables, imap_utf7, parameters
class WMtable(tables.Table):
tableid = "emails"
idkey = "imapid"
# selection = tables.SelectionColumn("selection", width="20px", first=True)
_1_flags = tables.ImgColumn("flags", width="4%",
header="<input type='checkbox' name='toggleselect' id='toggleselect' />")
_2_subject = tables.Column("subject", label=_("Subject"),
+5 -2
View File
@@ -34,6 +34,11 @@ def init():
parameters.register("webmail", "SMTP_SECURED", "list_yesno", "no",
help=_("Use a secured connection to access SMTP server"))
def destroy():
events.unregister("UserMenuDisplay", menu)
events.unregister("UserLogin", userlogin)
parameters.unregister_app("webmail")
def infos():
return {
"name" : "Webmail",
@@ -139,14 +144,12 @@ def viewmail(request, folder, mail_id=None):
def getmailcontent(request, folder, mail_id):
msg = fetchmail(request, folder, mail_id, True)
if "class" in msg.keys() and msg["class"] == "unseen":
#IMAPconnector(request).msg_read(*msg["imapid"].split("/"))
IMAPconnector(request).msg_read(folder, mail_id)
email = ImapEmail(msg, mode="html", links="1")
try:
pageid = request.session["page"]
except KeyError:
pageid = "1"
#folder, imapid = msg["imapid"].split("/")
return _render(request, "common/viewmail.html", {
"headers" : email.render_headers(folder, mail_id),
"folder" : folder, "imapid" : mail_id, "mailbody" : email.body,