exemple of a simple script to use with xml mapping and vcards :
1 vcard_string_list = []
2 first_name = context.getFirstName()
3 last_name = context.getLastName()
4 tel = context.getDefaultTelephoneTelephoneNumber()
5
6 if same_type(first_name, u'a'):
7 first_name = first_name.encode('utf-8')
8 if same_type(last_name, u'a'):
9 last_name = last_name.encode('utf-8')
10 if same_type(tel, u'a') :
11 tel = tel.encode('utf-8')
12
13 parameters_FN = ''
14 parameters_N = ''
15
16 try:
17 first_name.encode('utf-8')
18 except:
19 parameters_FN = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8'
20
21 try:
22 last_name.encode('utf-8')
23 except:
24 parameters_N = ';ENCODING=QUOTED-PRINTABLE;CHARSET=UTF-8'
25
26 append = vcard_string_list.append
27 append('BEGIN:VCARD\n')
28 append('VERSION:2.1\n')
29 if first_name not in (None, ''):
30 append('FN%s:%s\n' % (parameters_FN, first_name))
31 if last_name not in (None, ''):
32 if parameters_N == '':
33 parameters = parameters_FN
34 else:
35 parameters = parameters_N
36 append('N%s:%s;%s;;;\n' % (parameters, last_name, first_name))
37 else:
38 append('N%s:;%s;;;\n' % (parameters_N, first_name))
39 if tel not in (None, ''):
40 append('TEL:%s\n' % tel)
41 append('END:VCARD')
42
43 return "".join(vcard_string_list)