comparison roundup/cgi/client.py @ 1689:aca6de3e5eac

fix :required ordering problem [SF#740214]
author Richard Jones <richard@users.sourceforge.net>
date Tue, 24 Jun 2003 03:51:15 +0000
parents b87c40d1b8fb
children 388b9bfe4483
comparison
equal deleted inserted replaced
1688:a351beb8220a 1689:aca6de3e5eac
1 # $Id: client.py,v 1.120 2003-06-24 03:30:30 richard Exp $ 1 # $Id: client.py,v 1.121 2003-06-24 03:51:15 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
1504 If the edit action is "@link@", the simple form 1504 If the edit action is "@link@", the simple form
1505 variable must specify a Link or Multilink property. 1505 variable must specify a Link or Multilink property.
1506 The form value is a comma-separated list of 1506 The form value is a comma-separated list of
1507 designators. The item corresponding to each 1507 designators. The item corresponding to each
1508 designator is linked to the property given by simple 1508 designator is linked to the property given by simple
1509 form variable. 1509 form variable. These are collected up and returned in
1510 1510 all_links.
1511 XXX Used to add a link to new items created during edit.
1512 XXX These are collected up and returned in all_links. This will
1513 XXX result in an additional linking operation (either Link set or
1514 XXX Multilink append) after the edit/create is done using
1515 XXX all_props in _editnodes. The <propname> on the current item
1516 XXX will be set/appended the id of the newly created item of
1517 XXX class <designator> (where <designator> must be
1518 XXX <classname>-<N>).
1519 1511
1520 None of the above (ie. just a simple form value) 1512 None of the above (ie. just a simple form value)
1521 The value of the form variable is converted 1513 The value of the form variable is converted
1522 appropriately, depending on the type of the property. 1514 appropriately, depending on the type of the property.
1523 1515
1603 default_cn = self.classname 1595 default_cn = self.classname
1604 default_cl = self.db.classes[default_cn] 1596 default_cl = self.db.classes[default_cn]
1605 default_nodeid = self.nodeid 1597 default_nodeid = self.nodeid
1606 1598
1607 # we'll store info about the individual class/item edit in these 1599 # we'll store info about the individual class/item edit in these
1608 all_required = {} # one entry per class/item 1600 all_required = {} # required props per class/item
1609 all_props = {} # one entry per class/item 1601 all_props = {} # props present per class/item
1610 all_propdef = {} # note - only one entry per class 1602 all_propdef = {} # note - only one entry per class
1611 all_links = [] # as many as are required 1603 all_links = [] # as many as are required
1612 1604
1613 # we should always return something, even empty, for the context 1605 # we should always return something, even empty, for the context
1614 all_props[(default_cn, default_nodeid)] = {} 1606 all_props[(default_cn, default_nodeid)] = {}
1692 1684
1693 # detect the special ":required" variable 1685 # detect the special ":required" variable
1694 if d['required']: 1686 if d['required']:
1695 all_required[this] = extractFormList(form[key]) 1687 all_required[this] = extractFormList(form[key])
1696 continue 1688 continue
1697
1698 # get the required values list
1699 if not all_required.has_key(this):
1700 all_required[this] = []
1701 required = all_required[this]
1702 1689
1703 # see if we're performing a special multilink action 1690 # see if we're performing a special multilink action
1704 mlaction = 'set' 1691 mlaction = 'set'
1705 if d['remove']: 1692 if d['remove']:
1706 mlaction = 'remove' 1693 mlaction = 'remove'
1917 elif isinstance(proptype, hyperdb.String) and value == '': 1904 elif isinstance(proptype, hyperdb.String) and value == '':
1918 continue 1905 continue
1919 1906
1920 props[propname] = value 1907 props[propname] = value
1921 1908
1922 # register this as received if required?
1923 if propname in required and value is not None:
1924 required.remove(propname)
1925
1926 # check to see if we need to specially link a file to the note 1909 # check to see if we need to specially link a file to the note
1927 if have_note and have_file: 1910 if have_note and have_file:
1928 all_links.append(('msg', '-1', 'files', [('file', '-1')])) 1911 all_links.append(('msg', '-1', 'files', [('file', '-1')]))
1929 1912
1930 # see if all the required properties have been supplied 1913 # see if all the required properties have been supplied
1931 s = [] 1914 s = []
1932 for thing, required in all_required.items(): 1915 for thing, required in all_required.items():
1916 # register the values we got
1917 got = all_props.get(thing, {})
1918 for entry in required:
1919 if got.get(entry, ''):
1920 required.remove(entry)
1921
1922 # any required values not present?
1933 if not required: 1923 if not required:
1934 continue 1924 continue
1935 if len(required) > 1: 1925 if len(required) > 1:
1936 p = 'properties' 1926 p = 'properties'
1937 else: 1927 else:

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