Compound Fields¶
-
class
DateYYYYMMDD
(value=Unspecified, **kw)¶ Bases:
flatland.schema.compound.Compound
,flatland.schema.scalars.Date
-
compose
()¶ Return a text, native tuple built from children’s state.
Returns: a 2-tuple of text representation, native value. These correspond to the serialize_element()
andadapt_element()
methods ofScalar
objects.For example, a compound date field may return a ‘-‘ delimited string of year, month and day digits and a
datetime.date
.
-
explode
(value)¶ Given a compound value, assign values to children.
Parameters: value – a value to be adapted and exploded For example, a compound date field may read attributes from a
datetime.date
value andset()
them on child fields.The decision to perform type checking on value is completely up to you and you may find you want different rules for different compound types.
-
-
class
JoinedString
(value=Unspecified, **kw)¶ Bases:
flatland.schema.containers.Array
,flatland.schema.scalars.String
A sequence container that acts like a compounded string such as CSV.
Marshals child element values to and from a single string:
>>> from flatland import JoinedString >>> el = JoinedString(['x', 'y', 'z']) >>> el.value u'x,y,z' >>> el2 = JoinedString('foo,bar') >>> el2[1].value u'bar' >>> el2.value u'foo,bar'
Only the joined representation is considered when flattening or restoring with
set_flat()
. JoinedStrings run validation after their children.-
member_schema
¶ alias of
flatland.schema.scalars.String
-
set
(value)¶ Assign the native and Unicode value.
Attempts to adapt the given iterable and assigns this element’s
value
andu
attributes in tandem. Returns True if the adaptation was successful. SeeElement.set()
.Set must be supplied a Python sequence or iterable:
>>> from flatland import Integer, List >>> Numbers = List.of(Integer) >>> nums = Numbers() >>> nums.set([1, 2, 3, 4]) True >>> nums.value [1, 2, 3, 4]
-
u
¶ A read-only
separator
-joined string of child values.
-
value
¶ A read-only
separator
-joined string of child values.
-