Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/local/bin/python
2# encoding: utf-8
3"""
4*The model get for the `models_xmatches_views_get.py` resource*
6:Author:
7 David Young
8"""
9from future import standard_library
10standard_library.install_aliases()
11from builtins import zip
12from builtins import object
13import sys
14import os
15import khufu
16import collections
17import urllib.request
18import urllib.parse
19import urllib.error
20import re
21from dryxPyramid.models.models_base import base_model
23class models_xmatches_views_get(base_model):
24 """
25 The worker class for the models_xmatches_views_get module
27 **Key Arguments**
29 - ``log`` -- logger
30 - ``request`` -- the pyramid request
31 - ``elementId`` -- the specific element id requests (or False)
33 """
35 def __init__(self, log, request, elementId=False, search=False):
36 super().__init__(log, request, elementId, search)
37 self.resourceName = "xmatches_views"
38 self.defaultQs = {
39 "sortBy": "top_ranked_transient_associations",
40 "sortDesc": True
41 }
42 self._set_default_parameters()
44 log.debug(
45 "instansiating a new 'models_xmatches_views_get' object")
46 return None
48 def get(self):
49 """execute the get method on the models_xmatches_views_get object
51 **Return**
53 - ``responseContent`` -- the reponse to send to the browser
55 """
56 self.log.debug('starting the ``get`` method')
58 sortBy = self.qs["sortBy"]
59 if self.qs["sortDesc"] == True or self.qs["sortDesc"].lower() == "true":
60 sortDesc = "desc"
61 else:
62 sortDesc = ""
64 sqlQuery = u"""
65 select * from tcs_stats_catalogues where transientStream = 0 order by %(sortBy)s %(sortDesc)s
66 """ % locals()
67 objectDataTmp = self.request.db.execute(sqlQuery).fetchall()
68 objectData = []
69 objectData[:] = [dict(list(zip(list(row.keys()), row)))
70 for row in objectDataTmp]
72 responseContent = objectData
74 self.log.debug('completed the ``get`` method')
75 return responseContent
77 # xt-class-method