# $Id: client.py,v 1.124 2003-06-24 05:00:43 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). """ import os, os.path, cgi, StringIO, urlparse, re, traceback, mimetypes, urllib import binascii, Cookie, time, random, MimeWriter, smtplib, socket, quopri import stat, rfc822, string from roundup import roundupdb, date, hyperdb, password, token from roundup.i18n import _ from roundup.cgi.templating import Templates, HTMLRequest, NoTemplate from roundup.cgi import cgitb from roundup.cgi.PageTemplates import PageTemplate from roundup.rfc2822 import encode_header from roundup.mailgw import uidFromAddress, openSMTPConnection class HTTPException(Exception): pass class Unauthorised(HTTPException): pass class NotFound(HTTPException): pass class Redirect(HTTPException): pass class NotModified(HTTPException): pass # set to indicate to roundup not to actually _send_ email # this var must contain a file to write the mail to SENDMAILDEBUG = os.environ.get('SENDMAILDEBUG', '') # used by a couple of routines chars = string.letters+string.digits # XXX actually _use_ FormError class FormError(ValueError): ''' An "expected" exception occurred during form parsing. - ie. something we know can go wrong, and don't want to alarm the user with We trap this at the user interface level and feed back a nice error to the user. ''' pass class SendFile(Exception): ''' Send a file from the database ''' class SendStaticFile(Exception): ''' Send a static file from the instance html directory ''' def initialiseSecurity(security): ''' Create some Permissions and Roles on the security object This function is directly invoked by security.Security.__init__() as a part of the Security object instantiation. ''' security.addPermission(name="Web Registration", description="User may register through the web") p = security.addPermission(name="Web Access", description="User may access the web interface") security.addPermissionToRole('Admin', p) # doing Role stuff through the web - make sure Admin can p = security.addPermission(name="Web Roles", description="User may manipulate user Roles through the web") security.addPermissionToRole('Admin', p) # used to clean messages passed through CGI variables - HTML-escape any tag # that isn't , , and
(including XHTML variants) so # that people can't pass through nasties like