3 from ...util import none_or
4 from .collection import Collection
6 logger = logging.getLogger("mw.database.collections.pages")
9 class Pages(Collection):
10 def get(self, page_id=None, namespace_title=None, rev_id=None):
12 Gets a single page based on a legitimate identifier of the page. Note
13 that namespace_title expects a tuple of namespace ID and title.
18 namespace_title : ( int, str )
19 the page's namespace ID and title
21 a revision ID included in the page's history
24 iterator over result rows
27 page_id = none_or(page_id, int)
28 namespace_title = none_or(namespace_title, tuple)
29 rev_id = none_or(rev_id, int)
37 if page_id is not None:
41 values.append(page_id)
43 if namespace_title is not None:
44 namespace, title = namespace_title
46 query += " WHERE page_namespace = %s and page_title = %s "
47 values.extend([int(namespace), str(title)])
49 elif rev_id is not None:
51 WHERE page_id = (SELECT rev_page FROM revision WHERE rev_id = %s)
56 raise TypeError("Must specify a page identifier.")
58 cursor = self.db.shared_connection.cursor()