Mercurial > p > roundup > code
comparison roundup/hyperdb.py @ 3668:a15c15510e99
hyperdb handling of empty raw values for Multilink and Password [SF#1507814]
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 11 Aug 2006 04:50:24 +0000 |
| parents | 53987aa153d2 |
| children | 193f316dbbe9 |
comparison
equal
deleted
inserted
replaced
| 3667:35811df7c783 | 3668:a15c15510e99 |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: hyperdb.py,v 1.122 2006-07-13 10:14:56 schlatterbeck Exp $ | 18 # $Id: hyperdb.py,v 1.123 2006-08-11 04:50:24 richard Exp $ |
| 19 | 19 |
| 20 """Hyperdatabase implementation, especially field types. | 20 """Hyperdatabase implementation, especially field types. |
| 21 """ | 21 """ |
| 22 __docformat__ = 'restructuredtext' | 22 __docformat__ = 'restructuredtext' |
| 23 | 23 |
| 46 """An object designating a Password property.""" | 46 """An object designating a Password property.""" |
| 47 def __repr__(self): | 47 def __repr__(self): |
| 48 ' more useful for dumps ' | 48 ' more useful for dumps ' |
| 49 return '<%s>'%self.__class__ | 49 return '<%s>'%self.__class__ |
| 50 def from_raw(self, value, **kw): | 50 def from_raw(self, value, **kw): |
| 51 if not value: | |
| 52 return None | |
| 51 m = password.Password.pwre.match(value) | 53 m = password.Password.pwre.match(value) |
| 52 if m: | 54 if m: |
| 53 # password is being given to us encrypted | 55 # password is being given to us encrypted |
| 54 p = password.Password() | 56 p = password.Password() |
| 55 p.scheme = m.group(1) | 57 p.scheme = m.group(1) |
| 134 self.do_journal = do_journal == 'yes' | 136 self.do_journal = do_journal == 'yes' |
| 135 def __repr__(self): | 137 def __repr__(self): |
| 136 ' more useful for dumps ' | 138 ' more useful for dumps ' |
| 137 return '<%s to "%s">'%(self.__class__, self.classname) | 139 return '<%s to "%s">'%(self.__class__, self.classname) |
| 138 def from_raw(self, value, db, klass, propname, itemid, **kw): | 140 def from_raw(self, value, db, klass, propname, itemid, **kw): |
| 141 if not value: | |
| 142 return [] | |
| 143 | |
| 139 # get the current item value if it's not a new item | 144 # get the current item value if it's not a new item |
| 140 if itemid and not itemid.startswith('-'): | 145 if itemid and not itemid.startswith('-'): |
| 141 curvalue = klass.get(itemid, propname) | 146 curvalue = klass.get(itemid, propname) |
| 142 else: | 147 else: |
| 143 curvalue = [] | 148 curvalue = [] |
| 903 klass.classname) | 908 klass.classname) |
| 904 | 909 |
| 905 # if we got a string, strip it now | 910 # if we got a string, strip it now |
| 906 if isinstance(value, type('')): | 911 if isinstance(value, type('')): |
| 907 value = value.strip() | 912 value = value.strip() |
| 913 | |
| 908 # convert the input value to a real property value | 914 # convert the input value to a real property value |
| 909 value = proptype.from_raw \ | 915 value = proptype.from_raw(value, db=db, klass=klass, |
| 910 ( value | 916 propname=propname, itemid=itemid, **kw) |
| 911 , db = db | 917 |
| 912 , klass = klass | |
| 913 , propname = propname | |
| 914 , itemid = itemid | |
| 915 , **kw | |
| 916 ) | |
| 917 return value | 918 return value |
| 918 | 919 |
| 919 class FileClass: | 920 class FileClass: |
| 920 ''' A class that requires the "content" property and stores it on | 921 ''' A class that requires the "content" property and stores it on |
| 921 disk. | 922 disk. |
