Hide keyboard shortcuts

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_searches_get.py` resource* 

5 

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 

22 

23class models_xmatches_searches_get(base_model): 

24 """ 

25 The worker class for the models_xmatches_searches_get module 

26 

27 **Key Arguments** 

28 

29 - ``log`` -- logger 

30 - ``request`` -- the pyramid request 

31 - ``elementId`` -- the specific element id requests (or False) 

32  

33 """ 

34 

35 def __init__(self, log, request, elementId=False, search=False): 

36 super().__init__(log, request, elementId, search) 

37 self.resourceName = "xmatches_searches" 

38 self.defaultQs = { 

39 "sortBy": "top_ranked_transient_associations", 

40 "sortDesc": True 

41 } 

42 self._set_default_parameters() 

43 

44 log.debug( 

45 "instansiating a new 'models_xmatches_searches_get' object") 

46 return None 

47 

48 def get(self): 

49 """execute the get method on the models_xmatches_searches_get object 

50 

51 **Return** 

52 

53 - ``responseContent`` -- the reponse to send to the browser 

54  

55 """ 

56 self.log.debug('starting the ``get`` method') 

57 

58 sortBy = self.qs["sortBy"] 

59 if self.qs["sortDesc"] == True or self.qs["sortDesc"].lower() == "true": 

60 sortDesc = "desc" 

61 else: 

62 sortDesc = "" 

63 

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] 

71 

72 responseContent = objectData 

73 

74 self.log.debug('completed the ``get`` method') 

75 return responseContent 

76 

77 # xt-class-method