Skip to content

Commit 3b123a6

Browse files
author
Gordon B. McMillan
committed
Adapt metakit backend to new security scheme.
Put some more permission checks in cgi_client.
1 parent 80b7eb5 commit 3b123a6

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

roundup/backends/back_metakit.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def __init__(self, config, journaltag=None):
1919
self.config = config
2020
self.journaltag = journaltag
2121
self.classes = {}
22-
self._classes = []
2322
self.dirty = 0
2423
self.lockfile = None
2524
self._db = self.__open()

roundup/cgi_client.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: cgi_client.py,v 1.148 2002-07-30 16:09:11 gmcm Exp $
18+
# $Id: cgi_client.py,v 1.149 2002-07-30 20:04:38 gmcm Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -709,22 +709,26 @@ def shownode(self, message=None, num_re=re.compile('^\d+$')):
709709
# don't try to set properties if the user has just logged in
710710
if keys and not self.form.has_key('__login_name'):
711711
try:
712-
props = parsePropsFromForm(self.db, cl, self.form, self.nodeid)
713-
# make changes to the node
714-
self._changenode(props)
715-
# handle linked nodes
716-
self._post_editnode(self.nodeid)
717-
# and some nice feedback for the user
718-
if props:
719-
message = _('%(changes)s edited ok')%{'changes':
720-
', '.join(props.keys())}
721-
elif self.form.has_key('__note') and self.form['__note'].value:
722-
message = _('note added')
723-
elif (self.form.has_key('__file') and
724-
self.form['__file'].filename):
725-
message = _('file added')
712+
userid = self.db.user.lookup(self.user)
713+
if not self.db.security.hasPermission('Edit', userid):
714+
message = _('You do not have permission to edit %s' %cn)
726715
else:
727-
message = _('nothing changed')
716+
props = parsePropsFromForm(self.db, cl, self.form, self.nodeid)
717+
# make changes to the node
718+
self._changenode(props)
719+
# handle linked nodes
720+
self._post_editnode(self.nodeid)
721+
# and some nice feedback for the user
722+
if props:
723+
message = _('%(changes)s edited ok')%{'changes':
724+
', '.join(props.keys())}
725+
elif self.form.has_key('__note') and self.form['__note'].value:
726+
message = _('note added')
727+
elif (self.form.has_key('__file') and
728+
self.form['__file'].filename):
729+
message = _('file added')
730+
else:
731+
message = _('nothing changed')
728732
except:
729733
self.db.rollback()
730734
s = StringIO.StringIO()
@@ -911,7 +915,7 @@ def _post_editnode(self, nid):
911915
if type(value) != type([]): value = [value]
912916
for value in value:
913917
designator, property = value.split(':')
914-
link, nodeid = roundupdb.splitDesignator(designator)
918+
link, nodeid = hyperdb.splitDesignator(designator)
915919
link = self.db.classes[link]
916920
# take a dupe of the list so we're not changing the cache
917921
value = link.get(nodeid, property)[:]
@@ -922,7 +926,7 @@ def _post_editnode(self, nid):
922926
if type(value) != type([]): value = [value]
923927
for value in value:
924928
designator, property = value.split(':')
925-
link, nodeid = roundupdb.splitDesignator(designator)
929+
link, nodeid = hyperdb.splitDesignator(designator)
926930
link = self.db.classes[link]
927931
link.set(nodeid, **{property: nid})
928932

@@ -1370,7 +1374,7 @@ def set_cookie(self, user, password):
13701374
self.db.sessions.set(self.session, user=user, last_use=time.time())
13711375

13721376
# and commit immediately
1373-
self.db.commit()
1377+
self.db.sessions.commit()
13741378

13751379
# expire us in a long, long time
13761380
expire = Cookie._getdate(86400*365)
@@ -1446,7 +1450,6 @@ def main_action(self):
14461450

14471451
# get the session key from the cookie
14481452
self.session = cookie['roundup_user'].value
1449-
14501453
# get the user from the session
14511454
try:
14521455
# update the lifetime datestamp
@@ -1459,7 +1462,7 @@ def main_action(self):
14591462
# sanity check on the user still being valid
14601463
try:
14611464
self.db.user.lookup(user)
1462-
except KeyError:
1465+
except (KeyError, TypeError):
14631466
user = 'anonymous'
14641467

14651468
# make sure the anonymous user is valid if we're using it
@@ -1692,6 +1695,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
16921695

16931696
#
16941697
# $Log: not supported by cvs2svn $
1698+
# Revision 1.148 2002/07/30 16:09:11 gmcm
1699+
# Simple optimization.
1700+
#
16951701
# Revision 1.147 2002/07/30 08:22:38 richard
16961702
# Session storage in the hyperdb was horribly, horribly inefficient. We use
16971703
# a simple anydbm wrapper now - which could be overridden by the metakit

0 commit comments

Comments
 (0)