Skip to content

Commit 9df271f

Browse files
author
Gordon B. McMillan
committed
If the form has a :multilink, put a back href in the pageheader...
...(back to the linked-to node). Some minor optimizations (only compile regexes once).
1 parent 2c53bf9 commit 9df271f

File tree

1 file changed

+32
-12
lines changed

1 file changed

+32
-12
lines changed

roundup/cgi_client.py

Lines changed: 32 additions & 12 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.129 2002-06-20 23:52:11 richard Exp $
18+
# $Id: cgi_client.py,v 1.130 2002-06-27 12:01:53 gmcm Exp $
1919

2020
__doc__ = """
2121
WWW request handler (also used in the stand-alone server).
@@ -561,15 +561,20 @@ def classhelp(self):
561561
w('</tr>')
562562
w('</table>')
563563

564-
def shownode(self, message=None):
564+
def shownode(self, message=None, num_re=re.compile('^\d+$')):
565565
''' display an item
566566
'''
567567
cn = self.classname
568568
cl = self.db.classes[cn]
569+
if self.form.has_key(':multilink'):
570+
link = self.form[':multilink'].value
571+
designator, linkprop = link.split(':')
572+
xtra = ' for <a href="%s">%s</a>' % (designator, designator)
573+
else:
574+
xtra = ''
569575

570576
# possibly perform an edit
571577
keys = self.form.keys()
572-
num_re = re.compile('^\d+$')
573578
# don't try to set properties if the user has just logged in
574579
if keys and not self.form.has_key('__login_name'):
575580
try:
@@ -599,7 +604,7 @@ def shownode(self, message=None):
599604
id = self.nodeid
600605
if cl.getkey():
601606
id = cl.get(id, cl.getkey())
602-
self.pagehead('%s: %s'%(self.classname.capitalize(), id), message)
607+
self.pagehead('%s: %s %s'%(self.classname.capitalize(), id, xtra), message)
603608

604609
nodeid = self.nodeid
605610

@@ -763,6 +768,12 @@ def newnode(self, message=None):
763768
'''
764769
cn = self.classname
765770
cl = self.db.classes[cn]
771+
if self.form.has_key(':multilink'):
772+
link = self.form[':multilink'].value
773+
designator, linkprop = link.split(':')
774+
xtra = ' for <a href="%s">%s</a>' % (designator, designator)
775+
else:
776+
xtra = ''
766777

767778
# possibly perform a create
768779
keys = self.form.keys()
@@ -790,8 +801,9 @@ def newnode(self, message=None):
790801
s = StringIO.StringIO()
791802
traceback.print_exc(None, s)
792803
message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
793-
self.pagehead(_('New %(classname)s')%{'classname':
794-
self.classname.capitalize()}, message)
804+
self.pagehead(_('New %(classname)s %(xtra)s')%{
805+
'classname': self.classname.capitalize(),
806+
'xtra': xtra }, message)
795807

796808
# call the template
797809
newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
@@ -843,6 +855,12 @@ def newfile(self, message=None):
843855
cn = self.classname
844856
cl = self.db.classes[cn]
845857
props = parsePropsFromForm(self.db, cl, self.form)
858+
if self.form.has_key(':multilink'):
859+
link = self.form[':multilink'].value
860+
designator, linkprop = link.split(':')
861+
xtra = ' for <a href="%s">%s</a>' % (designator, designator)
862+
else:
863+
xtra = ''
846864

847865
# possibly perform a create
848866
keys = self.form.keys()
@@ -867,14 +885,15 @@ def newfile(self, message=None):
867885
traceback.print_exc(None, s)
868886
message = '<pre>%s</pre>'%cgi.escape(s.getvalue())
869887

870-
self.pagehead(_('New %(classname)s')%{'classname':
871-
self.classname.capitalize()}, message)
888+
self.pagehead(_('New %(classname)s %(xtra)s')%{
889+
'classname': self.classname.capitalize(),
890+
'xtra': xtra }, message)
872891
newitem = htmltemplate.NewItemTemplate(self, self.instance.TEMPLATES,
873892
self.classname)
874893
newitem.render(self.form)
875894
self.pagefoot()
876895

877-
def showuser(self, message=None):
896+
def showuser(self, message=None, num_re=re.compile('^\d+$')):
878897
'''Display a user page for editing. Make sure the user is allowed
879898
to edit this node, and also check for password changes.
880899
'''
@@ -893,7 +912,6 @@ def showuser(self, message=None):
893912
# perform any editing
894913
#
895914
keys = self.form.keys()
896-
num_re = re.compile('^\d+$')
897915
if keys:
898916
try:
899917
props = parsePropsFromForm(self.db, user, self.form,
@@ -1294,12 +1312,11 @@ class ExtendedClient(Client):
12941312
default_index_columns = ['activity','status','title','assignedto']
12951313
default_index_filterspec = {'status': ['1', '2', '3', '4', '5', '6', '7']}
12961314

1297-
def parsePropsFromForm(db, cl, form, nodeid=0):
1315+
def parsePropsFromForm(db, cl, form, nodeid=0, num_re=re.compile('^\d+$')):
12981316
'''Pull properties for the given class out of the form.
12991317
'''
13001318
props = {}
13011319
keys = form.keys()
1302-
num_re = re.compile('^\d+$')
13031320
for key in keys:
13041321
if not cl.properties.has_key(key):
13051322
continue
@@ -1375,6 +1392,9 @@ def parsePropsFromForm(db, cl, form, nodeid=0):
13751392

13761393
#
13771394
# $Log: not supported by cvs2svn $
1395+
# Revision 1.129 2002/06/20 23:52:11 richard
1396+
# Better handling of unauth attempt to edit stuff
1397+
#
13781398
# Revision 1.128 2002/06/12 21:28:25 gmcm
13791399
# Allow form to set user-properties on a Fileclass.
13801400
# Don't assume that a Fileclass is named "files".

0 commit comments

Comments
 (0)