Mercurial > p > roundup > code
comparison roundup/cgi/client.py @ 1692:64f448ff07f2
audit some user properties for valid values (roles, address)
[SF#742968] and [SF#739653]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Tue, 24 Jun 2003 04:16:35 +0000 |
| parents | 388b9bfe4483 |
| children | c9f67f2f7ba7 |
comparison
equal
deleted
inserted
replaced
| 1690:388b9bfe4483 | 1692:64f448ff07f2 |
|---|---|
| 1 # $Id: client.py,v 1.122 2003-06-24 03:58:57 richard Exp $ | 1 # $Id: client.py,v 1.123 2003-06-24 04:16:35 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 |
| 1596 default_cl = self.db.classes[default_cn] | 1596 default_cl = self.db.classes[default_cn] |
| 1597 default_nodeid = self.nodeid | 1597 default_nodeid = self.nodeid |
| 1598 | 1598 |
| 1599 # 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 |
| 1600 all_required = {} # required props per class/item | 1600 all_required = {} # required props per class/item |
| 1601 all_props = {} # props present per class/item | 1601 all_props = {} # props to set per class/item |
| 1602 got_props = {} # props received per class/item | |
| 1602 all_propdef = {} # note - only one entry per class | 1603 all_propdef = {} # note - only one entry per class |
| 1603 all_links = [] # as many as are required | 1604 all_links = [] # as many as are required |
| 1604 | 1605 |
| 1605 # we should always return something, even empty, for the context | 1606 # we should always return something, even empty, for the context |
| 1606 all_props[(default_cn, default_nodeid)] = {} | 1607 all_props[(default_cn, default_nodeid)] = {} |
| 1660 all_propdef[cn] = cl.getprops() | 1661 all_propdef[cn] = cl.getprops() |
| 1661 propdef = all_propdef[cn] | 1662 propdef = all_propdef[cn] |
| 1662 if not all_props.has_key(this): | 1663 if not all_props.has_key(this): |
| 1663 all_props[this] = {} | 1664 all_props[this] = {} |
| 1664 props = all_props[this] | 1665 props = all_props[this] |
| 1666 if not got_props.has_key(this): | |
| 1667 got_props[this] = {} | |
| 1665 | 1668 |
| 1666 # is this a link command? | 1669 # is this a link command? |
| 1667 if d['link']: | 1670 if d['link']: |
| 1668 value = [] | 1671 value = [] |
| 1669 for entry in extractFormList(form[key]): | 1672 for entry in extractFormList(form[key]): |
| 1864 value = float(value) | 1867 value = float(value) |
| 1865 except ValueError, msg: | 1868 except ValueError, msg: |
| 1866 raise ValueError, _('Error with %s property: %s')%( | 1869 raise ValueError, _('Error with %s property: %s')%( |
| 1867 propname, msg) | 1870 propname, msg) |
| 1868 | 1871 |
| 1872 # register that we got this property | |
| 1873 if value: | |
| 1874 got_props[this][propname] = 1 | |
| 1875 | |
| 1869 # get the old value | 1876 # get the old value |
| 1870 if nodeid and not nodeid.startswith('-'): | 1877 if nodeid and not nodeid.startswith('-'): |
| 1871 try: | 1878 try: |
| 1872 existing = cl.get(nodeid, propname) | 1879 existing = cl.get(nodeid, propname) |
| 1873 except KeyError: | 1880 except KeyError: |
| 1912 | 1919 |
| 1913 # see if all the required properties have been supplied | 1920 # see if all the required properties have been supplied |
| 1914 s = [] | 1921 s = [] |
| 1915 for thing, required in all_required.items(): | 1922 for thing, required in all_required.items(): |
| 1916 # register the values we got | 1923 # register the values we got |
| 1917 got = all_props.get(thing, {}) | 1924 got = got_props.get(thing, {}) |
| 1918 for entry in required[:]: | 1925 for entry in required[:]: |
| 1919 if got.get(entry, ''): | 1926 if got.has_key(entry): |
| 1920 required.remove(entry) | 1927 required.remove(entry) |
| 1921 | 1928 |
| 1922 # any required values not present? | 1929 # any required values not present? |
| 1923 if not required: | 1930 if not required: |
| 1924 continue | 1931 continue |
