1 """
2 I am the content handler for a set of mimetypes using attribute-value pairs.
3 """
4
5 import urllib
6
7
8
10 """Is this content likely to handle a content with that mimetype.
11
12 Return an int between 00 and 99, indicating the likelyhood of this handler
13 to handle correctly the given mimetype. 70 is used as a standard value when
14 the hanlder is pretty sure it can handle the mimetype.
15 """
16 if mimetype in [
17 "application/x-advene-builtin-view",
18 "application/x-advene-type-constraint",
19 'application/x-advene-structured',
20 ]:
21 return 99
22 else:
23 return 0
24
26 """
27 Parse the content of the given package element, and return the produced
28 object.
29 """
30 r = {}
31 for l in obj.content_data.splitlines():
32 if not l:
33 continue
34 if '=' in l:
35 key, val = l.split("=", 1)
36 key = key.strip()
37 val = val.strip()
38 r[key] = urllib.unquote_plus(val)
39 else:
40 r['_error']=l
41 print "Syntax error in content: >%s<" % l.encode('utf8')
42 return r
43
45 """
46 Serializes (or unparse) an object produced by `parse_content` into a
47 string.
48 """
49 r = ""
50 for k,v in obj.iteritems():
51 r += "%s = %s\n" % (k, urllib.quote_plus(v))
52 return r
53