mirror of https://github.com/scrapy/scrapy.git
calculate ItemField.default on __init__
--HG-- extra : convert_revision : svn%3Ab85faa78-f9eb-468e-a121-7cced6da292c%40880
This commit is contained in:
parent
db4ccaf78f
commit
81ce9bd458
|
|
@ -14,7 +14,7 @@ class ItemFieldValueError(Exception):
|
|||
class ItemField(object):
|
||||
def __init__(self, required=False, default=None):
|
||||
self.required = required
|
||||
self._default = default
|
||||
self.default = default or self.to_python(None)
|
||||
|
||||
def assign(self, value):
|
||||
if hasattr(value, '__iter__'):
|
||||
|
|
@ -33,11 +33,6 @@ class ItemField(object):
|
|||
"Converts the input iterable into a single value."
|
||||
return ' '.join(value)
|
||||
|
||||
@property
|
||||
def default(self):
|
||||
"Returns the default value for this field"
|
||||
return self._default or self.to_python(None)
|
||||
|
||||
|
||||
class BooleanItemField(ItemField):
|
||||
def to_python(self, value):
|
||||
|
|
|
|||
Loading…
Reference in New Issue