Revision: 8078
http://svn.sourceforge.net/mailman/?rev=8078&view=rev
Author: mindlace23
Date: 2006-10-22 13:39:49 -0700 (Sun, 22 Oct 2006)
Log Message:
-----------
attempting to be more integrated with Mailman/HttpRunner
Modified Paths:
--------------
branches/soc2006-webui/Mailman/Makefile.in
Added Paths:
-----------
branches/soc2006-webui/Mailman/WebUI/
branches/soc2006-webui/Mailman/WebUI/lists.py
branches/soc2006-webui/Mailman/WebUI/newlist.py
branches/soc2006-webui/Mailman/WebUI/page.py
branches/soc2006-webui/Mailman/WebUI/post.py
branches/soc2006-webui/Mailman/WebUI/static/
branches/soc2006-webui/Mailman/WebUI/templates/
branches/soc2006-webui/Mailman/WebUI/wsgi_app.py
Modified: branches/soc2006-webui/Mailman/Makefile.in
===================================================================
--- branches/soc2006-webui/Mailman/Makefile.in 2006-10-22 18:05:39 UTC (rev
8077)
+++ branches/soc2006-webui/Mailman/Makefile.in 2006-10-22 20:39:49 UTC (rev
8078)
@@ -43,7 +43,7 @@
SHELL= /bin/sh
MODULES= $(srcdir)/*.py
-SUBDIRS= Cgi Archiver Handlers Bouncers Queue MTA Gui DB Commands \
+SUBDIRS= Cgi Archiver Handlers Bouncers Queue MTA Gui DB WebUI Commands \
bin testing
# Modes for directories and executables created by the install
Added: branches/soc2006-webui/Mailman/WebUI/lists.py
===================================================================
--- branches/soc2006-webui/Mailman/WebUI/lists.py
(rev 0)
+++ branches/soc2006-webui/Mailman/WebUI/lists.py 2006-10-22 20:39:49 UTC
(rev 8078)
@@ -0,0 +1,48 @@
+# Copyright (C) 2006 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+from page import Page
+from Mailman.Utils import list_names
+
+class Lists(Page):
+ def __call__(self, environ, start_response):
+ hostname = environ.get('HTTP_HOST')
+ self.context['sitename'] = hostname[:hostname.rfind(':')]
+ if self.context['bm'].anonymous:
+ self.add_piece('signin','controls')
+
+ self.lists()
+ start_response('200 OK', [('content-type','application/xhtml+xml')])
+ self.render_template('content.html')
+
+ def lists(self):
+ names = list_names()
+ if not names:
+ self.context['lists'] = []
+ self.context['no_lists'] = True
+ return
+
+ advertised = []
+ for name in names:
+ mlist = self.listmodule(name, lock=False)
+ if mlist.advertised:
+ if self.context['sitename'] not in mlist.web_page_url:
+ continue
+ else:
+ advertised.append(mlist)
+
+ self.context['lists'] = advertised
\ No newline at end of file
Added: branches/soc2006-webui/Mailman/WebUI/newlist.py
===================================================================
Added: branches/soc2006-webui/Mailman/WebUI/page.py
===================================================================
--- branches/soc2006-webui/Mailman/WebUI/page.py
(rev 0)
+++ branches/soc2006-webui/Mailman/WebUI/page.py 2006-10-22 20:39:49 UTC
(rev 8078)
@@ -0,0 +1,57 @@
+# Copyright (C) 2006 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+
+from genshi.template import TemplateLoader
+from os.path import join
+
+class Page(object):
+ def __init__(self, config):
+ self.template_loader = TemplateLoader(
+ search_path=join(config['VAR_PREFIX'],'Mailman/WebUI/templates'),
+ auto_reload=True)
+ self.context = {'bm': BiteMarks(), 'moderationRequests': doNothing,
+ 'location': doNothing, 'pieces': []
+ }
+
+ def render_template(self, template_name, context=None):
+ if not context: context = self.context
+ template = self.template_loader.load(template_name)
+ stream = template.generate(**context)
+ return stream.render(method='xhtml')
+
+ def add_piece(self, piecename, attribute_match):
+ self.context['pieces'].append('pieces/'+piecename+'.html')
+ self.context[piecename+'_content'] = attribute_match
+
+class BiteMarks(object):
+ """Provides 'identity' services"""
+ roles = ('list_member','list_moderator','list_administrator',
+ 'domain_administrator','site_administrator')
+
+ def __init__(self):
+ self.anonymous = True
+ self.role = None
+ self.administers_anything = False
+
+ def as_good_as(self,role):
+ if not self.role:
+ return False
+ return self.roles.index(self.role) >= self.roles.index(role)
+
+def doNothing(*args, **kwargs):
+ pass
\ No newline at end of file
Added: branches/soc2006-webui/Mailman/WebUI/post.py
===================================================================
Copied: branches/soc2006-webui/Mailman/WebUI/static (from rev 8076,
branches/soc2006-webui/XUI/xui/static)
Copied: branches/soc2006-webui/Mailman/WebUI/templates (from rev 8076,
branches/soc2006-webui/XUI/xui/templates)
Added: branches/soc2006-webui/Mailman/WebUI/wsgi_app.py
===================================================================
--- branches/soc2006-webui/Mailman/WebUI/wsgi_app.py
(rev 0)
+++ branches/soc2006-webui/Mailman/WebUI/wsgi_app.py 2006-10-22 20:39:49 UTC
(rev 8078)
@@ -0,0 +1,103 @@
+# Copyright (C) 2006 by the Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+# USA.
+
+from os.path import join
+import cgi
+
+from wsgiref.utils import shift_path_info
+
+from paste.fileapp import FileApp
+from genshi.template import TemplateLoader
+
+from Mailman.configuration import config
+from Mailman.Utils import list_names
+
+class WebUI(object):
+ def __init__(self):
+ self.config = config
+ config.load()
+ self.list_names = list_names()
+
+ def __call__(self, environ, start_response):
+ # Reverse proxy environment.
+ if environ.has_key('HTTP_X_FORWARDED_HOST'):
+ environ['HTTP_HOST'] = environ['HTTP_X_FORWARDED_HOST']
+ if environ.has_key('HTTP_X_FORWARDED_FOR'):
+ environ['REMOTE_HOST'] = environ['HTTP_X_FORWARDED_FOR']
+
+ pathparts = path.split('/')
+
+ # handle requests for 'static' data with paste's FileApp
+ if pathparts[1] in ('static','templates'):
+ filename = join(config['VAR_PREFIX'],
+ 'Mailman/WebUI',
+ path[1:])
+ fa = FileApp(filename)
+ return fa(environ, start_response)
+
+ if self.is_post_request(environ):
+ self.parse_post_form(environ)
+ return post(environ, start_response)
+ path = environ['PATH_INFO']
+ # render the lists page
+ if path == '/':
+ return lists(environ, start_response)
+
+ # render the list page
+ if (pathparts[1] == 'newlist') or (pathparts[1] in self.list_names):
+ shift_path_info(environ)
+ return list(environ, start_response)
+
+ def parse_post_form(environ):
+ """Because we are accepting all form elements on a page, we need
+ to know which have actually been submitted. Therefore form elements
+ are prefixed with their associated control, and a dictionary of
+ {'controlname':{'fieldname':value(s)}} is created. The submit button
+ for a control that was actually submitted just has the controlname,
+ so we add a 'submitted' value to the dictionary representing the
+ submitted form.
+ """
+ input = environ['wsgi.input']
+ fs = cgi.FieldStorage(fp=input,
+ environ=environ,
+ keep_blank_values=1)
+ formvars = {}
+ if isinstance(fs.value, list):
+ no_namespace = []
+ for name in fs.keys():
+ if name.find(':') != -1:
+ prefix, subname = name.split(':')
+ if formvars.has_key('prefix'):
+ formvars[prefix].update({subname:fs[name]})
+ else:
+ formvars[prefix] = {subname:fs[name]}
+ else:
+ no_namespace.append(name)
+ for name in no_namespace:
+ if formvars.has_key(name):
+ formvars[name].update({'submitted':True})
+ else:
+ formvars[name] = fs[name]
+
+ environ['webui.form'] = formvars
+
+ def is_post_request(environ):
+ if environ['REQUEST_METHOD'].upper() != 'POST':
+ return False
+ content_type = environ.get('CONTENT_TYPE',
'application/x-www-form-urlencoded')
+ return (content_type.startswith('application/x-www-form-urlencoded')
+ or content_type.startswith('multipart/form-data'))
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Mailman-checkins mailing list
[email protected]
Unsubscribe:
http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org