Skip to content

Commit f119074

Browse files
author
Johannes Gijsbers
committed
Some reformatting and fixing docstrings for emacs.
1 parent b5a4284 commit f119074

File tree

1 file changed

+38
-37
lines changed

1 file changed

+38
-37
lines changed

roundup/cgi/client.py

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Id: client.py,v 1.147 2003-11-21 21:59:05 jlgijsbers Exp $
1+
# $Id: client.py,v 1.148 2003-11-21 22:22:32 jlgijsbers Exp $
22

33
__doc__ = """
44
WWW request handler (also used in the stand-alone server).
@@ -18,27 +18,27 @@
1818
from roundup.mailer import Mailer, MessageSendError
1919

2020
class HTTPException(Exception):
21-
pass
22-
class Unauthorised(HTTPException):
23-
pass
24-
class NotFound(HTTPException):
25-
pass
26-
class Redirect(HTTPException):
27-
pass
28-
class NotModified(HTTPException):
29-
pass
21+
pass
22+
class Unauthorised(HTTPException):
23+
pass
24+
class NotFound(HTTPException):
25+
pass
26+
class Redirect(HTTPException):
27+
pass
28+
class NotModified(HTTPException):
29+
pass
3030

3131
# used by a couple of routines
3232
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
3333

3434
class FormError(ValueError):
35-
''' An "expected" exception occurred during form parsing.
35+
""" An "expected" exception occurred during form parsing.
3636
- ie. something we know can go wrong, and don't want to alarm the
3737
user with
3838
3939
We trap this at the user interface level and feed back a nice error
4040
to the user.
41-
'''
41+
"""
4242
pass
4343

4444
class SendFile(Exception):
@@ -287,13 +287,12 @@ def inner_main(self):
287287
self.write(cgitb.html())
288288

289289
def clean_sessions(self):
290-
''' Age sessions, remove when they haven't been used for a week.
290+
"""Age sessions, remove when they haven't been used for a week.
291291
292-
Do it only once an hour.
292+
Do it only once an hour.
293293
294-
Note: also cleans One Time Keys, and other "session" based
295-
stuff.
296-
'''
294+
Note: also cleans One Time Keys, and other "session" based stuff.
295+
"""
297296
sessions = self.db.sessions
298297
last_clean = sessions.get('last_clean', 'last_use') or 0
299298

@@ -315,7 +314,7 @@ def clean_sessions(self):
315314
sessions.set('last_clean', last_use=time.time())
316315

317316
def determine_user(self):
318-
''' Determine who the user is
317+
'''Determine who the user is.
319318
'''
320319
# open the database as admin
321320
self.opendb('admin')
@@ -362,7 +361,7 @@ def determine_user(self):
362361
self.opendb(self.user)
363362

364363
def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
365-
''' Determine the context of this page from the URL:
364+
""" Determine the context of this page from the URL:
366365
367366
The URL path after the instance identifier is examined. The path
368367
is generally only one entry long.
@@ -397,7 +396,7 @@ def determine_context(self, dre=re.compile(r'([^\d]+)(\d+)')):
397396
self.classname - the class to display, can be None
398397
self.template - the template to render the current context with
399398
self.nodeid - the nodeid of the class we're displaying
400-
'''
399+
"""
401400
# default the optional variables
402401
self.classname = None
403402
self.nodeid = None
@@ -595,9 +594,10 @@ def header(self, headers=None, response=None):
595594
self.headers_sent = headers
596595

597596
def set_cookie(self, user):
598-
''' Set up a session cookie for the user and store away the user's
599-
login info against the session.
600-
'''
597+
"""Set up a session cookie for the user.
598+
599+
Also store away the user's login info against the session.
600+
"""
601601
# TODO generate a much, much stronger session key ;)
602602
self.session = binascii.b2a_base64(repr(random.random())).strip()
603603

@@ -883,7 +883,8 @@ def passResetAction(self):
883883
if not self.standard_message([address], subject, body):
884884
return
885885

886-
self.ok_message.append('Password reset and email sent to %s'%address)
886+
self.ok_message.append('Password reset and email sent to %s' %
887+
address)
887888
return
888889

889890
# no OTK, so now figure the user
@@ -953,13 +954,13 @@ def editItemAction(self):
953954
newItemAction = editItemAction
954955

955956
def editItemPermission(self, props):
956-
''' Determine whether the user has permission to edit this item.
957+
"""Determine whether the user has permission to edit this item.
957958
958-
Base behaviour is to check the user can edit this class. If we're
959-
editing the "user" class, users are allowed to edit their own
960-
details. Unless it's the "roles" property, which requires the
961-
special Permission "Web Roles".
962-
'''
959+
Base behaviour is to check the user can edit this class. If we're
960+
editing the"user" class, users are allowed to edit their own details.
961+
Unless it's the "roles" property, which requires the special Permission
962+
"Web Roles".
963+
"""
963964
# if this is a user node and the user is editing their own node, then
964965
# we're OK
965966
has = self.db.security.hasPermission
@@ -1116,12 +1117,12 @@ def _createnode(self, cn, props):
11161117
# More actions
11171118
#
11181119
def editCSVAction(self):
1119-
''' Performs an edit of all of a class' items in one go.
1120+
""" Performs an edit of all of a class' items in one go.
11201121
11211122
The "rows" CGI var defines the CSV-formatted entries for the
11221123
class. New nodes are identified by the ID 'X' (or any other
11231124
non-existent ID) and removed lines are retired.
1124-
'''
1125+
"""
11251126
# this is per-class only
11261127
if not self.editCSVPermission():
11271128
self.error_message.append(
@@ -1366,7 +1367,7 @@ def showAction(self, typere=re.compile('[@:]type'),
13661367
raise Redirect, url
13671368

13681369
def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
1369-
''' Item properties and their values are edited with html FORM
1370+
""" Item properties and their values are edited with html FORM
13701371
variables and their values. You can:
13711372
13721373
- Change the value of some property of the current item.
@@ -1506,7 +1507,7 @@ def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
15061507
doesn't result in any changes would return {('issue','123'): {}})
15071508
The id may be None, which indicates that an item should be
15081509
created.
1509-
'''
1510+
"""
15101511
# some very useful variables
15111512
db = self.db
15121513
form = self.form
@@ -1835,10 +1836,10 @@ def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
18351836
for (cn, id), props in all_props.items():
18361837
if isinstance(self.db.classes[cn], hyperdb.FileClass):
18371838
if id == '-1':
1838-
if not props.get('content', ''):
1839-
del all_props[(cn, id)]
1839+
if not props.get('content', ''):
1840+
del all_props[(cn, id)]
18401841
elif props.has_key('content') and not props['content']:
1841-
raise FormError, _('File is empty')
1842+
raise FormError, _('File is empty')
18421843
return all_props, all_links
18431844

18441845
def extractFormList(value):

0 commit comments

Comments
 (0)