[Vobject] vCard 2.1 behaviour

martin f krafft madduck at madduck.net
Thu Oct 25 03:48:37 CDT 2012


Meanwhile, I found
http://jppy.sourcearchive.com/documentation/0.0.45/vcard_8py-source.html

Unfortunately, the behaviour exhibited is actually identical to
VCard3_0, which is to be excpected when you look at it — it does not
actually specify any behaviour.

Apart from the encoding, which in vCard 3.0 is proper standardised
Unicode+Base64, vCard 2.1 is ASCII and ASCII-encoded, where the
encoding and charset are specified with the ENCODING and CHARSET
variables as part of the properties of the field, e.g.

  ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=ISO-8859-1:Meinestra=DFe

I think (hope) that vObjects store data in Unicode. It should not be
hard to write up proper encoding/decoding for serialisation and
reading, but I can't quite figure out where to start.

encode/decode are class methods of the object behaviour, and this
makes sense. However, there are also field behaviours, e.g.
NameBehavior.

Is it true that by calling e.g.

  registerBehavior(NameBehavior, 'N')

I am telling vObject to apply this behaviour to the value of
all 'N' fields, and if no specific behaviour is registered for
a field, then a default behaviour, VCardTextBehavior, is used?

So for a 2.1 vCard, I would define a class NameBehavior2_1, call
registerBehaviour(NameBehavior2_1, 'N2_1') and then configure the
VCard2_1 behaviour's knownChildren to contain

  N: (1,1,'N2_1')

right?

If the above holds, then vobject is truly well designed.

To recap, taking the above line, and assuming for a minute that ADR
needs special handling for vCards 2.1:

  ADR;ENCODING=QUOTED-PRINTABLE;CHARSET=ISO-8859-1:Meinestra=DFe

The behaviour for the ADR field registered it AdrBehaviour. Now the
following steps happen on readOne():

  1. AdrBehaviour.decode receives the ContentLine object holding the
     above, decoding it to the internal representation (Unicode?)

  2. AdrBehaviour.transformToNative is called to turn the value into
     an internal object, an Address in this case.

On serialize(), the following happens:

  1. AdrBehaviour.transformFromNative is called, which turns the
     object's value into vCard representation
     (;;Street;ZIP;State;Country)

  2. AdrBehaviour.encode is called to turn the entire ContentLine
     into vCard2.1-compatible text, e.g. encoding it to Base64 or
     QuotedPrintable.

  3. AdrBehaviour.serialize is called to serialize the ContentLine.

Thanks for any thoughts an input, which should greatly facilitate
coding this up in one go.

-- 
martin | http://madduck.net/ | http://two.sentenc.es/
 
"i sometimes think that god
 in creating man
 somewhat overestimated his ability."
                                                        -- oscar wilde
 
spamtraps: madduck.bogus at madduck.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 1124 bytes
Desc: Digital signature (see http://martin-krafft.net/gpg/sig-policy/999bbcc4/current)
URL: <http://lists.skyhouseconsulting.com/pipermail/vobject/attachments/20121025/129b4c10/attachment.pgp>


More information about the VObject mailing list