comparison roundup/cgi/form_parser.py @ 3656:0119e04886d8

@required in forms may now specify properties of linked items (patch [SF#1507093])
author Richard Jones <richard@users.sourceforge.net>
date Fri, 11 Aug 2006 00:18:59 +0000
parents 5004aeed5a3a
children 9a00da0f1da9
comparison
equal deleted inserted replaced
3655:8169e97a6f26 3656:0119e04886d8
282 if not m: 282 if not m:
283 raise FormError, self._('link "%(key)s" ' 283 raise FormError, self._('link "%(key)s" '
284 'value "%(entry)s" not a designator') % locals() 284 'value "%(entry)s" not a designator') % locals()
285 value.append((m.group(1), m.group(2))) 285 value.append((m.group(1), m.group(2)))
286 286
287 # get details of linked class
288 lcn = m.group(1)
289 lcl = self.db.classes[lcn]
290 lnodeid = m.group(2)
291 if not all_propdef.has_key(lcn):
292 all_propdef[lcn] = lcl.getprops()
293 if not all_props.has_key((lcn, lnodeid)):
294 all_props[(lcn, lnodeid)] = {}
295 if not got_props.has_key((lcn, lnodeid)):
296 got_props[(lcn, lnodeid)] = {}
297
287 # make sure the link property is valid 298 # make sure the link property is valid
288 if (not isinstance(propdef[propname], hyperdb.Multilink) and 299 if (not isinstance(propdef[propname], hyperdb.Multilink) and
289 not isinstance(propdef[propname], hyperdb.Link)): 300 not isinstance(propdef[propname], hyperdb.Link)):
290 raise FormError, self._('%(class)s %(property)s ' 301 raise FormError, self._('%(class)s %(property)s '
291 'is not a link or multilink property') % { 302 'is not a link or multilink property') % {
294 all_links.append((cn, nodeid, propname, value)) 305 all_links.append((cn, nodeid, propname, value))
295 continue 306 continue
296 307
297 # detect the special ":required" variable 308 # detect the special ":required" variable
298 if d['required']: 309 if d['required']:
299 all_required[this] = self.extractFormList(form[key]) 310 for entry in self.extractFormList(form[key]):
311 m = self.FV_SPECIAL.match(entry)
312 if not m:
313 raise FormError, self._('The form action claims to '
314 'require property "%(property)s" '
315 'which doesn\'t exist') % {
316 'property':propname}
317 if m.group('classname'):
318 this = (m.group('classname'), m.group('id'))
319 entry = m.group('propname')
320 if not all_required.has_key(this):
321 all_required[this] = []
322 all_required[this].append(entry)
300 continue 323 continue
301 324
302 # see if we're performing a special multilink action 325 # see if we're performing a special multilink action
303 mlaction = 'set' 326 mlaction = 'set'
304 if d['remove']: 327 if d['remove']:

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