comparison roundup/cgi/client.py @ 1436:2f6647cf5345

bugger, dropping support for "+" special char
author Richard Jones <richard@users.sourceforge.net>
date Mon, 17 Feb 2003 00:39:28 +0000
parents a866491d04a7
children 077235194ac2
comparison
equal deleted inserted replaced
1435:a866491d04a7 1436:2f6647cf5345
1 # $Id: client.py,v 1.86 2003-02-16 22:57:09 richard Exp $ 1 # $Id: client.py,v 1.87 2003-02-17 00:39:28 richard Exp $
2 2
3 __doc__ = """ 3 __doc__ = """
4 WWW request handler (also used in the stand-alone server). 4 WWW request handler (also used in the stand-alone server).
5 """ 5 """
6 6
81 81
82 82
83 Special form variables: 83 Special form variables:
84 Note that in various places throughout this code, special form 84 Note that in various places throughout this code, special form
85 variables of the form :<name> are used. The colon (":") part may 85 variables of the form :<name> are used. The colon (":") part may
86 actually be one of several characters from the set: 86 actually be one of either ":" or "@".
87
88 : @ +
89
90 ''' 87 '''
91 88
92 # 89 #
93 # special form variables 90 # special form variables
94 # 91 #
95 FV_TEMPLATE = re.compile(r'[@+:]template') 92 FV_TEMPLATE = re.compile(r'[@:]template')
96 FV_OK_MESSAGE = re.compile(r'[@+:]ok_message') 93 FV_OK_MESSAGE = re.compile(r'[@:]ok_message')
97 FV_ERROR_MESSAGE = re.compile(r'[@+:]error_message') 94 FV_ERROR_MESSAGE = re.compile(r'[@:]error_message')
98 95
99 # specials for parsePropsFromForm 96 # specials for parsePropsFromForm
100 FV_REQUIRED = re.compile(r'[@+:]required') 97 FV_REQUIRED = re.compile(r'[@:]required')
101 FV_ADD = re.compile(r'([@+:])add\1') 98 FV_ADD = re.compile(r'([@:])add\1')
102 FV_REMOVE = re.compile(r'([@+:])remove\1') 99 FV_REMOVE = re.compile(r'([@:])remove\1')
103 FV_CONFIRM = re.compile(r'.+[@+:]confirm') 100 FV_CONFIRM = re.compile(r'.+[@:]confirm')
104 FV_LINK = re.compile(r'([@+:])link\1(.+)') 101 FV_LINK = re.compile(r'([@:])link\1(.+)')
105 102
106 # deprecated 103 # deprecated
107 FV_NOTE = re.compile(r'[@+:]note') 104 FV_NOTE = re.compile(r'[@:]note')
108 FV_FILE = re.compile(r'[@+:]file') 105 FV_FILE = re.compile(r'[@:]file')
109 106
110 # Note: index page stuff doesn't appear here: 107 # Note: index page stuff doesn't appear here:
111 # columns, sort, sortdir, filter, group, groupdir, search_text, 108 # columns, sort, sortdir, filter, group, groupdir, search_text,
112 # pagesize, startwith 109 # pagesize, startwith
113 110
753 750
754 This follows the same form as the editItemAction, with the same 751 This follows the same form as the editItemAction, with the same
755 special form values. 752 special form values.
756 ''' 753 '''
757 # parse the props from the form 754 # parse the props from the form
755 # XXX reinstate exception handling
758 # try: 756 # try:
759 if 1: 757 if 1:
760 props, links = self.parsePropsFromForm() 758 props, links = self.parsePropsFromForm()
761 # except (ValueError, KeyError), message: 759 # except (ValueError, KeyError), message:
762 # self.error_message.append(_('Error: ') + str(message)) 760 # self.error_message.append(_('Error: ') + str(message))
763 # return 761 # return
764 762
765 # handle the props - edit or create 763 # handle the props - edit or create
764 # XXX reinstate exception handling
766 # try: 765 # try:
767 if 1: 766 if 1:
768 # create the context here 767 # create the context here
769 cn = self.classname 768 cn = self.classname
770 nid = self._createnode(cn, props[(cn, None)]) 769 nid = self._createnode(cn, props[(cn, None)])
783 782
784 # commit now that all the tricky stuff is done 783 # commit now that all the tricky stuff is done
785 self.db.commit() 784 self.db.commit()
786 785
787 # redirect to the new item's page 786 # redirect to the new item's page
788 raise Redirect, '%s%s%s?:ok_message=%s'%(self.base, self.classname, 787 raise Redirect, '%s%s%s?@ok_message=%s'%(self.base, self.classname,
789 nid, urllib.quote(messages)) 788 nid, urllib.quote(messages))
790 789
791 def newItemPermission(self, props): 790 def newItemPermission(self, props):
792 ''' Determine whether the user has permission to create (edit) this 791 ''' Determine whether the user has permission to create (edit) this
793 item. 792 item.
908 if not self.searchPermission(): 907 if not self.searchPermission():
909 self.error_message.append( 908 self.error_message.append(
910 _('You do not have permission to search %s' %self.classname)) 909 _('You do not have permission to search %s' %self.classname))
911 910
912 # add a faked :filter form variable for each filtering prop 911 # add a faked :filter form variable for each filtering prop
912 # XXX migrate to new : @ +
913 props = self.db.classes[self.classname].getprops() 913 props = self.db.classes[self.classname].getprops()
914 for key in self.form.keys(): 914 for key in self.form.keys():
915 if not props.has_key(key): continue 915 if not props.has_key(key): continue
916 if isinstance(self.form[key], type([])): 916 if isinstance(self.form[key], type([])):
917 # search for at least one entry which is not empty 917 # search for at least one entry which is not empty
1002 1002
1003 1003
1004 def showAction(self): 1004 def showAction(self):
1005 ''' Show a node 1005 ''' Show a node
1006 ''' 1006 '''
1007 # XXX allow : @ +
1007 t = self.form[':type'].value 1008 t = self.form[':type'].value
1008 n = self.form[':number'].value 1009 n = self.form[':number'].value
1009 url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n) 1010 url = '%s%s%s'%(self.db.config.TRACKER_WEB, t, n)
1010 raise Redirect, url 1011 raise Redirect, url
1011 1012
1095 1096
1096 def parsePropsFromForm(self, num_re=re.compile('^\d+$')): 1097 def parsePropsFromForm(self, num_re=re.compile('^\d+$')):
1097 ''' Pull properties for the given class out of the form. 1098 ''' Pull properties for the given class out of the form.
1098 1099
1099 In the following, <bracketed> values are variable, ":" may be 1100 In the following, <bracketed> values are variable, ":" may be
1100 any of : @ + and other text "required" is fixed. 1101 one of ":" or "@", and other text "required" is fixed.
1101 1102
1102 Properties are specified as form variables 1103 Properties are specified as form variables
1103 <designator>:<propname> 1104 <designator>:<propname>
1104 1105
1105 where the propery belongs to the context class or item if the 1106 where the propery belongs to the context class or item if the
1124 Multilink append) after the edit/create is done using 1125 Multilink append) after the edit/create is done using
1125 all_props in _editnodes. The <propname> on 1126 all_props in _editnodes. The <propname> on
1126 [classname|designator] will be set/appended the id of the 1127 [classname|designator] will be set/appended the id of the
1127 newly created item of class <classname>. 1128 newly created item of class <classname>.
1128 1129
1129 Note: the colon may be one of: : @ + 1130 Note: the colon may be either ":" or "@".
1130 1131
1131 Any of the form variables may be prefixed with a classname or 1132 Any of the form variables may be prefixed with a classname or
1132 designator. 1133 designator.
1133 1134
1134 The return from this method is a dict of 1135 The return from this method is a dict of
1156 1157
1157 if not hasattr(self, 'FV_ITEMSPEC'): 1158 if not hasattr(self, 'FV_ITEMSPEC'):
1158 # generate the regexp for detecting 1159 # generate the regexp for detecting
1159 # <classname|designator>[@:+]property 1160 # <classname|designator>[@:+]property
1160 classes = '|'.join(db.classes.keys()) 1161 classes = '|'.join(db.classes.keys())
1161 self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@+:](.+)$'%classes) 1162 self.FV_ITEMSPEC = re.compile(r'(%s)([-\d]+)[@:](.+)$'%classes)
1162 self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)'%classes) 1163 self.FV_DESIGNATOR = re.compile(r'(%s)([-\d]+)'%classes)
1163 1164
1164 # these indicate the default class / item 1165 # these indicate the default class / item
1165 default_cn = self.classname 1166 default_cn = self.classname
1166 default_cl = self.db.classes[default_cn] 1167 default_cl = self.db.classes[default_cn]

Roundup Issue Tracker: http://roundup-tracker.org/