From: richard Date: Wed, 12 Feb 2003 07:02:24 +0000 (+0000) Subject: oops, forgot the templating :) X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=33bc9e7dcbc79ec3fdbcd8e120c1f5288e919433;p=roundup.git oops, forgot the templating :) git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1499 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/cgi/client.py b/roundup/cgi/client.py index ef3d2ad..8d42f45 100644 --- a/roundup/cgi/client.py +++ b/roundup/cgi/client.py @@ -1,4 +1,4 @@ -# $Id: client.py,v 1.79 2003-02-12 06:41:58 richard Exp $ +# $Id: client.py,v 1.80 2003-02-12 07:02:22 richard Exp $ __doc__ = """ WWW request handler (also used in the stand-alone server). @@ -89,19 +89,30 @@ class Client: ''' + # # special form variables + # FV_TEMPLATE = re.compile(r'[@+:]template') FV_OK_MESSAGE = re.compile(r'[@+:]ok_message') FV_ERROR_MESSAGE = re.compile(r'[@+:]error_message') + + # specials for parsePropsFromForm FV_REQUIRED = re.compile(r'[@+:]required') + FV_ADD = re.compile(r'([@+:])add\1') + FV_REMOVE = re.compile(r'([@+:])remove\1') + FV_CONFIRM = re.compile(r'.+[@+:]confirm') + + # post-edi FV_LINK = re.compile(r'[@+:]link') FV_MULTILINK = re.compile(r'[@+:]multilink') + + # deprecated FV_NOTE = re.compile(r'[@+:]note') FV_FILE = re.compile(r'[@+:]file') - FV_ADD = re.compile(r'([@+:])add\1') - FV_REMOVE = re.compile(r'([@+:])remove\1') - FV_CONFIRM = re.compile(r'.+[@+:]confirm') - FV_SPLITTER = re.compile(r'[@+:]') + + # Note: index page stuff doesn't appear here: + # columns, sort, sortdir, filter, group, groupdir, search_text, + # pagesize, startwith def __init__(self, instance, request, env, form=None): hyperdb.traceMark() @@ -653,7 +664,7 @@ class Client: cl = self.db.user try: props['roles'] = self.instance.config.NEW_WEB_USER_ROLES - self.userid = cl.create(**props) + self.userid = cl.create(**props['user']) self.db.commit() except (ValueError, KeyError), message: self.error_message.append(message) @@ -724,10 +735,13 @@ class Client: self.__dict__)) return + # identify the entry in the props parsed from the form + this = self.classname + self.nodeid + # perform the edit try: # make changes to the node - props = self._changenode(props) + props = self._changenode(props[this]) # handle linked nodes self._post_editnode(self.nodeid) except (ValueError, KeyError, IndexError), message: @@ -803,7 +817,7 @@ class Client: try: # do the create - nid = self._createnode(props) + nid = self._createnode(props[self.classname]) except (ValueError, KeyError, IndexError), message: # these errors might just be indicative of user dumbness self.error_message.append(_('Error: ') + str(message)) diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index fc9713c..87243a7 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -1341,6 +1341,9 @@ class HTMLRequest: self.classname = client.classname self.template = client.template + # the special char to use for special vars + self.special_char = '@' + self._post_init() def _post_init(self): @@ -1348,36 +1351,46 @@ class HTMLRequest: ''' # extract the index display information from the form self.columns = [] - if self.form.has_key(':columns'): - self.columns = handleListCGIValue(self.form[':columns']) + for name in ':columns +columns @columns'.split(): + if self.form.has_key(name): + self.special_char = name[0] + self.columns = handleListCGIValue(self.form[name]) + break self.show = ShowDict(self.columns) # sorting self.sort = (None, None) - if self.form.has_key(':sort'): - sort = self.form[':sort'].value - if sort.startswith('-'): - self.sort = ('-', sort[1:]) - else: - self.sort = ('+', sort) - if self.form.has_key(':sortdir'): - self.sort = ('-', self.sort[1]) + for name in ':sort +sort @sort'.split(): + if self.form.has_key(name): + self.special_char = name[0] + sort = self.form[name].value + if sort.startswith('-'): + self.sort = ('-', sort[1:]) + else: + self.sort = ('+', sort) + if self.form.has_key(self.special_char+'sortdir'): + self.sort = ('-', self.sort[1]) # grouping self.group = (None, None) - if self.form.has_key(':group'): - group = self.form[':group'].value - if group.startswith('-'): - self.group = ('-', group[1:]) - else: - self.group = ('+', group) - if self.form.has_key(':groupdir'): - self.group = ('-', self.group[1]) + for name in ':group +group @group'.split(): + if self.form.has_key(name): + self.special_char = name[0] + group = self.form[name].value + if group.startswith('-'): + self.group = ('-', group[1:]) + else: + self.group = ('+', group) + if self.form.has_key(self.special_char+'groupdir'): + self.group = ('-', self.group[1]) # filtering self.filter = [] - if self.form.has_key(':filter'): - self.filter = handleListCGIValue(self.form[':filter']) + for name in ':filter +filter @filter'.split(): + if self.form.has_key(name): + self.special_char = name[0] + self.filter = handleListCGIValue(self.form[name]) + self.filterspec = {} db = self.client.db if self.classname is not None: @@ -1395,19 +1408,24 @@ class HTMLRequest: # full-text search argument self.search_text = None - if self.form.has_key(':search_text'): - self.search_text = self.form[':search_text'].value + for name in ':search_text +search_text @search_text'.split(): + if self.form.has_key(name): + self.special_char = name[0] + self.search_text = self.form[name].value # pagination - size and start index # figure batch args - if self.form.has_key(':pagesize'): - self.pagesize = int(self.form[':pagesize'].value) - else: - self.pagesize = 50 - if self.form.has_key(':startwith'): - self.startwith = int(self.form[':startwith'].value) - else: - self.startwith = 0 + self.pagesize = 50 + for name in ':pagesize +pagesize @pagesize'.split(): + if self.form.has_key(name): + self.special_char = name[0] + self.pagesize = int(self.form[name].value) + + self.startwith = 0 + for name in ':startwith +startwith @startwith'.split(): + if self.form.has_key(name): + self.special_char = name[0] + self.startwith = int(self.form[name].value) def updateFromURL(self, url): ''' Parse the URL for query args, and update my attributes using the @@ -1480,23 +1498,24 @@ env: %(env)s filterspec=1): ''' return the current index args as form elements ''' l = [] + sc = self.special_char s = '' if columns and self.columns: - l.append(s%(':columns', ','.join(self.columns))) + l.append(s%(sc+'columns', ','.join(self.columns))) if sort and self.sort[1] is not None: if self.sort[0] == '-': val = '-'+self.sort[1] else: val = self.sort[1] - l.append(s%(':sort', val)) + l.append(s%(sc+'sort', val)) if group and self.group[1] is not None: if self.group[0] == '-': val = '-'+self.group[1] else: val = self.group[1] - l.append(s%(':group', val)) + l.append(s%(sc+'group', val)) if filter and self.filter: - l.append(s%(':filter', ','.join(self.filter))) + l.append(s%(sc+'filter', ','.join(self.filter))) if filterspec: for k,v in self.filterspec.items(): if type(v) == type([]): @@ -1504,30 +1523,31 @@ env: %(env)s else: l.append(s%(k, v)) if self.search_text: - l.append(s%(':search_text', self.search_text)) - l.append(s%(':pagesize', self.pagesize)) - l.append(s%(':startwith', self.startwith)) + l.append(s%(sc+'search_text', self.search_text)) + l.append(s%(sc+'pagesize', self.pagesize)) + l.append(s%(sc+'startwith', self.startwith)) return '\n'.join(l) def indexargs_url(self, url, args): ''' embed the current index args in a URL ''' + sc = self.special_char l = ['%s=%s'%(k,v) for k,v in args.items()] if self.columns and not args.has_key(':columns'): - l.append(':columns=%s'%(','.join(self.columns))) + l.append(sc+'columns=%s'%(','.join(self.columns))) if self.sort[1] is not None and not args.has_key(':sort'): if self.sort[0] == '-': val = '-'+self.sort[1] else: val = self.sort[1] - l.append(':sort=%s'%val) + l.append(sc+'sort=%s'%val) if self.group[1] is not None and not args.has_key(':group'): if self.group[0] == '-': val = '-'+self.group[1] else: val = self.group[1] - l.append(':group=%s'%val) + l.append(sc+'group=%s'%val) if self.filter and not args.has_key(':filter'): - l.append(':filter=%s'%(','.join(self.filter))) + l.append(sc+'filter=%s'%(','.join(self.filter))) for k,v in self.filterspec.items(): if not args.has_key(k): if type(v) == type([]): @@ -1535,11 +1555,11 @@ env: %(env)s else: l.append('%s=%s'%(k, v)) if self.search_text and not args.has_key(':search_text'): - l.append(':search_text=%s'%self.search_text) + l.append(sc+'search_text=%s'%self.search_text) if not args.has_key(':pagesize'): - l.append(':pagesize=%s'%self.pagesize) + l.append(sc+'pagesize=%s'%self.pagesize) if not args.has_key(':startwith'): - l.append(':startwith=%s'%self.startwith) + l.append(sc+'startwith=%s'%self.startwith) return '%s?%s'%(url, '&'.join(l)) indexargs_href = indexargs_url