Skip to content

Commit 8a90334

Browse files
author
Alexander Smishlajev
committed
pychecker cleanup
1 parent 040fdc3 commit 8a90334

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

roundup/cgi/actions.py

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#$Id: actions.py,v 1.38 2004-11-18 15:58:23 a1s Exp $
1+
#$Id: actions.py,v 1.39 2004-11-18 17:20:40 a1s Exp $
22

33
import re, cgi, StringIO, urllib, Cookie, time, random
44

@@ -28,6 +28,10 @@ def __init__(self, client):
2828
self.user = client.user
2929
self.context = templating.context(client)
3030

31+
def handle(self):
32+
"""Action handler procedure"""
33+
raise NotImplementedError
34+
3135
def execute(self):
3236
"""Execute the action specified by this object."""
3337
self.permission()
@@ -68,14 +72,17 @@ def gettext(self, msgid):
6872
_ = gettext
6973

7074
class ShowAction(Action):
71-
def handle(self, typere=re.compile('[@:]type'),
72-
numre=re.compile('[@:]number')):
75+
76+
typere=re.compile('[@:]type')
77+
numre=re.compile('[@:]number')
78+
79+
def handle(self):
7380
"""Show a node of a particular class/id."""
7481
t = n = ''
7582
for key in self.form.keys():
76-
if typere.match(key):
83+
if self.typere.match(key):
7784
t = self.form[key].value.strip()
78-
elif numre.match(key):
85+
elif self.numre.match(key):
7986
n = self.form[key].value.strip()
8087
if not t:
8188
raise ValueError, self._('No type specified')
@@ -120,7 +127,7 @@ class SearchAction(Action):
120127
name = 'search'
121128
permissionType = 'View'
122129

123-
def handle(self, wcre=re.compile(r'[\s,]+')):
130+
def handle(self):
124131
"""Mangle some of the form variables.
125132
126133
Set the form ":filter" variable based on the values of the filter
@@ -317,9 +324,10 @@ def handle(self):
317324

318325
self.client.ok_message.append(self._('Items edited OK'))
319326

320-
class EditCommon:
327+
class EditCommon(Action):
321328
'''Utility methods for editing.'''
322-
def _editnodes(self, all_props, all_links, newids=None):
329+
330+
def _editnodes(self, all_props, all_links):
323331
''' Use the props in all_props to perform edit and creation, then
324332
use the link specs in all_links to do linking.
325333
'''
@@ -471,7 +479,7 @@ def newItemPermission(self, props):
471479
"""
472480
return self.hasPermission('Create', self.classname)
473481

474-
class EditItemAction(EditCommon, Action):
482+
class EditItemAction(EditCommon):
475483
def lastUserActivity(self):
476484
if self.form.has_key(':lastactivity'):
477485
d = date.Date(self.form[':lastactivity'].value)
@@ -491,6 +499,8 @@ def lastNodeActivity(self):
491499
def detectCollision(self, user_activity, node_activity):
492500
if user_activity:
493501
return user_activity < node_activity
502+
else:
503+
return 0
494504

495505
def handleCollision(self):
496506
self.client.template = 'collision'
@@ -535,7 +545,7 @@ def handle(self):
535545
url += '&' + req.indexargs_href('', {})[1:]
536546
raise exceptions.Redirect, url
537547

538-
class NewItemAction(EditCommon, Action):
548+
class NewItemAction(EditCommon):
539549
def handle(self):
540550
''' Add a new item to the database.
541551
@@ -673,7 +683,7 @@ def handle(self):
673683

674684
self.client.ok_message.append(self._('Email sent to %s') % address)
675685

676-
class RegoCommon:
686+
class RegoCommon(Action):
677687
def finishRego(self):
678688
# log the new user in
679689
self.client.userid = self.userid
@@ -702,7 +712,7 @@ def finishRego(self):
702712
window.setTimeout('window.location = "%s"', 1000);
703713
</script>'''%(message, url, message, url)
704714

705-
class ConfRegoAction(RegoCommon, Action):
715+
class ConfRegoAction(RegoCommon):
706716
def handle(self):
707717
"""Grab the OTK, use it to load up the new user details."""
708718
try:
@@ -713,7 +723,7 @@ def handle(self):
713723
return
714724
self.finishRego()
715725

716-
class RegisterAction(RegoCommon, EditCommon, Action):
726+
class RegisterAction(RegoCommon, EditCommon):
717727
name = 'register'
718728
permissionType = 'Create'
719729

@@ -758,7 +768,8 @@ def handle(self):
758768

759769
# finish off by logging the user in
760770
self.userid = self.nodeid
761-
return self.finishRego()
771+
self.finishRego()
772+
return
762773

763774
# generate the one-time-key and store the props for later
764775
for propname, proptype in self.db.user.getprops().items():
@@ -869,9 +880,8 @@ def verifyLogin(self, username, password):
869880
"You do not have permission to login")
870881

871882
def verifyPassword(self, userid, password):
872-
''' Verify the password that the user has supplied
873-
'''
874-
stored = self.db.user.get(self.client.userid, 'password')
883+
'''Verify the password that the user has supplied'''
884+
stored = self.db.user.get(userid, 'password')
875885
if password == stored:
876886
return 1
877887
if not password and not stored:
@@ -919,4 +929,4 @@ def handle(self):
919929

920930
return '\n'
921931

922-
# vim: set filetype=python ts=4 sw=4 et si :
932+
# vim: set filetype=python sts=4 sw=4 et si :

0 commit comments

Comments
 (0)