|
1 | | -# $Id: client.py,v 1.110 2003-03-26 03:35:00 richard Exp $ |
| 1 | +# $Id: client.py,v 1.111 2003-03-26 06:46:17 richard Exp $ |
2 | 2 |
|
3 | 3 | __doc__ = """ |
4 | 4 | WWW request handler (also used in the stand-alone server). |
@@ -1732,36 +1732,41 @@ class <designator> (where <designator> must be |
1732 | 1732 | # other types should be None'd if there's no value |
1733 | 1733 | value = None |
1734 | 1734 | else: |
1735 | | - if isinstance(proptype, hyperdb.String): |
1736 | | - if (hasattr(value, 'filename') and |
1737 | | - value.filename is not None): |
1738 | | - # skip if the upload is empty |
1739 | | - if not value.filename: |
1740 | | - continue |
1741 | | - # this String is actually a _file_ |
1742 | | - # try to determine the file content-type |
1743 | | - filename = value.filename.split('\\')[-1] |
1744 | | - if propdef.has_key('name'): |
1745 | | - props['name'] = filename |
1746 | | - # use this info as the type/filename properties |
1747 | | - if propdef.has_key('type'): |
1748 | | - props['type'] = mimetypes.guess_type(filename)[0] |
1749 | | - if not props['type']: |
1750 | | - props['type'] = "application/octet-stream" |
1751 | | - # finally, read the content |
1752 | | - value = value.value |
1753 | | - else: |
1754 | | - # normal String fix the CRLF/CR -> LF stuff |
1755 | | - value = fixNewlines(value) |
1756 | | - |
1757 | | - elif isinstance(proptype, hyperdb.Date): |
1758 | | - value = date.Date(value, offset=timezone) |
1759 | | - elif isinstance(proptype, hyperdb.Interval): |
1760 | | - value = date.Interval(value) |
1761 | | - elif isinstance(proptype, hyperdb.Boolean): |
1762 | | - value = value.lower() in ('yes', 'true', 'on', '1') |
1763 | | - elif isinstance(proptype, hyperdb.Number): |
1764 | | - value = float(value) |
| 1735 | + # handle ValueErrors for all these in a similar fashion |
| 1736 | + try: |
| 1737 | + if isinstance(proptype, hyperdb.String): |
| 1738 | + if (hasattr(value, 'filename') and |
| 1739 | + value.filename is not None): |
| 1740 | + # skip if the upload is empty |
| 1741 | + if not value.filename: |
| 1742 | + continue |
| 1743 | + # this String is actually a _file_ |
| 1744 | + # try to determine the file content-type |
| 1745 | + fn = value.filename.split('\\')[-1] |
| 1746 | + if propdef.has_key('name'): |
| 1747 | + props['name'] = fn |
| 1748 | + # use this info as the type/filename properties |
| 1749 | + if propdef.has_key('type'): |
| 1750 | + props['type'] = mimetypes.guess_type(fn)[0] |
| 1751 | + if not props['type']: |
| 1752 | + props['type'] = "application/octet-stream" |
| 1753 | + # finally, read the content |
| 1754 | + value = value.value |
| 1755 | + else: |
| 1756 | + # normal String fix the CRLF/CR -> LF stuff |
| 1757 | + value = fixNewlines(value) |
| 1758 | + |
| 1759 | + elif isinstance(proptype, hyperdb.Date): |
| 1760 | + value = date.Date(value, offset=timezone) |
| 1761 | + elif isinstance(proptype, hyperdb.Interval): |
| 1762 | + value = date.Interval(value) |
| 1763 | + elif isinstance(proptype, hyperdb.Boolean): |
| 1764 | + value = value.lower() in ('yes', 'true', 'on', '1') |
| 1765 | + elif isinstance(proptype, hyperdb.Number): |
| 1766 | + value = float(value) |
| 1767 | + except ValueError, msg: |
| 1768 | + raise ValueError, _('Error with %s property: %s')%( |
| 1769 | + propname, msg) |
1765 | 1770 |
|
1766 | 1771 | # get the old value |
1767 | 1772 | if nodeid and not nodeid.startswith('-'): |
|
0 commit comments