add a class method to construct the Address field from a dict
This commit is contained in:
parent
666489360f
commit
279db91ca8
|
@ -46,6 +46,14 @@ class Address(Field):
|
|||
'email': self.email,
|
||||
}
|
||||
|
||||
def from_dict(cls, d):
|
||||
o = cls()
|
||||
for attr in ('title', 'street', 'zipcode', 'city', 'phone1', 'phone2',
|
||||
'fax', 'email'):
|
||||
setattr(o, attr, d.get(attr))
|
||||
return o
|
||||
from_dict = classmethod(from_dict)
|
||||
|
||||
class IAddressWidget(IWidget):
|
||||
pass
|
||||
|
||||
|
|
Reference in New Issue