summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 571a978)
raw | patch | inline | side by side (parent: 571a978)
author | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 21 Nov 2003 22:22:32 +0000 (22:22 +0000) | ||
committer | jlgijsbers <jlgijsbers@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Fri, 21 Nov 2003 22:22:32 +0000 (22:22 +0000) |
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@2005 57a73879-2fb5-44c3-a270-3262357dd7e2
roundup/cgi/client.py | patch | blob | history |
diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py
index 8990d860f56371719a27c4ef9a0cfbdfe6883126..a72ae84c0b5b5272ed4250bee5db20fdc3620905 100644 (file)
--- a/roundup/cgi/client.py
+++ b/roundup/cgi/client.py
-# $Id: client.py,v 1.147 2003-11-21 21:59:05 jlgijsbers Exp $
+# $Id: client.py,v 1.148 2003-11-21 22:22:32 jlgijsbers Exp $
__doc__ = """
WWW request handler (also used in the stand-alone server).
from roundup.mailer import Mailer, MessageSendError
class HTTPException(Exception):
- pass
-class Unauthorised(HTTPException):
- pass
-class NotFound(HTTPException):
- pass
-class Redirect(HTTPException):
- pass
-class NotModified(HTTPException):
- pass
+ pass
+class Unauthorised(HTTPException):
+ pass
+class NotFound(HTTPException):
+ pass
+class Redirect(HTTPException):
+ pass
+class NotModified(HTTPException):
+ pass
# used by a couple of routines
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
class FormError(ValueError):
- ''' An "expected" exception occurred during form parsing.
+ """ 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):
self.write(cgitb.html())
def clean_sessions(self):
- ''' Age sessions, remove when they haven't been used for a week.
+ """Age sessions, remove when they haven't been used for a week.
- Do it only once an hour.
+ Do it only once an hour.
- Note: also cleans One Time Keys, and other "session" based
- stuff.
- '''
+ Note: also cleans One Time Keys, and other "session" based stuff.
+ """
sessions = self.db.sessions
last_clean = sessions.get('last_clean', 'last_use') or 0
sessions.set('last_clean', last_use=time.time())
def determine_user(self):
- ''' Determine who the user is
+ '''Determine who the user is.
'''
# open the database as admin
self.opendb('admin')
self.opendb(self.user)
def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
- ''' Determine the context of this page from the URL:
+ """ Determine the context of this page from the URL:
The URL path after the instance identifier is examined. The path
is generally only one entry long.
self.classname - the class to display, can be None
self.template - the template to render the current context with
self.nodeid - the nodeid of the class we're displaying
- '''
+ """
# default the optional variables
self.classname = None
self.nodeid = None
self.headers_sent = headers
def set_cookie(self, user):
- ''' Set up a session cookie for the user and store away the user's
- login info against the session.
- '''
+ """Set up a session cookie for the user.
+
+ Also store away the user's login info against the session.
+ """
# TODO generate a much, much stronger session key ;)
self.session = binascii.b2a_base64(repr(random.random())).strip()
if not self.standard_message([address], subject, body):
return
- self.ok_message.append('Password reset and email sent to %s'%address)
+ self.ok_message.append('Password reset and email sent to %s' %
+ address)
return
# no OTK, so now figure the user
newItemAction = editItemAction
def editItemPermission(self, props):
- ''' Determine whether the user has permission to edit this item.
+ """Determine whether the user has permission to edit this item.
- Base behaviour is to check the user can edit this class. If we're
- editing the "user" class, users are allowed to edit their own
- details. Unless it's the "roles" property, which requires the
- special Permission "Web Roles".
- '''
+ Base behaviour is to check the user can edit this class. If we're
+ editing the"user" class, users are allowed to edit their own details.
+ Unless it's the "roles" property, which requires the special Permission
+ "Web Roles".
+ """
# if this is a user node and the user is editing their own node, then
# we're OK
has = self.db.security.hasPermission
# More actions
#
def editCSVAction(self):
- ''' Performs an edit of all of a class' items in one go.
+ """ Performs an edit of all of a class' items in one go.
The "rows" CGI var defines the CSV-formatted entries for the
class. New nodes are identified by the ID 'X' (or any other
non-existent ID) and removed lines are retired.
- '''
+ """
# this is per-class only
if not self.editCSVPermission():
self.error_message.append(
raise Redirect, url
def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
- ''' Item properties and their values are edited with html FORM
+ """ Item properties and their values are edited with html FORM
variables and their values. You can:
- Change the value of some property of the current item.
doesn't result in any changes would return {('issue','123'): {}})
The id may be None, which indicates that an item should be
created.
- '''
+ """
# some very useful variables
db = self.db
form = self.form
for (cn, id), props in all_props.items():
if isinstance(self.db.classes[cn], hyperdb.FileClass):
if id == '-1':
- if not props.get('content', ''):
- del all_props[(cn, id)]
+ if not props.get('content', ''):
+ del all_props[(cn, id)]
elif props.has_key('content') and not props['content']:
- raise FormError, _('File is empty')
+ raise FormError, _('File is empty')
return all_props, all_links
def extractFormList(value):