1
2
3 __docformat__ = 'epytext en'
4 __all__ = ['OpenSearchQuery']
5
6 from amplee.ext.opensearch import OPENSEARCH_NS, OPENSEARCH_PREFIX
7 from amplee.utils import qname
8
11 self.role = role
12 self._title = None
13 self.total_results = None
14 self.search_terms = None
15 self.count = None
16 self.start_index = None
17 self.start_page = None
18 self.language = u'*'
19 self.input_encoding = u'utf-8'
20 self.output_encoding = u'utf-8'
21
22
23
24
27
29 if len(value) > 256:
30 raise ValueError("Query title must have a length inferior to 256 characters")
31
32 self._title = value
33
34 title = property(_get_title, _set_title,
35 doc="Gets or sets the title of the description document")
36
37
38
39
41 if not self.role:
42 raise ValueError("Query role must be set")
43
44 attrs = {u'role': self.role}
45
46 if self.title:
47 attrs[u'title'] = self.title
48
49 if self.total_results != None:
50 attrs[u'totalResults'] = unicode(self.total_results)
51
52 if self.start_index != None:
53 attrs[u'startIndex'] = unicode(self.start_index)
54
55 if self.start_page != None:
56 attrs[u'startPage'] = unicode(self.start_page)
57
58 if self.count != None:
59 attrs[u'count'] = unicode(self.count)
60
61 if self.search_terms:
62 attrs[u'searchTerms'] = self.search_terms
63
64 if self.language:
65 attrs[u'language'] = self.language
66
67 if self.input_encoding:
68 attrs[u'inputEncoding'] = self.input_encoding
69
70 if self.output_encoding:
71 attrs[u'outputEncoding'] = self.output_encoding
72
73 d = parent.ownerDocument
74 parent.xml_append(d.xml_create_element(qname(u"Query", OPENSEARCH_PREFIX),
75 ns=OPENSEARCH_NS, attributes=attrs))
76