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 HTML template module for the `models_transients_comments_get.py` resource*
6:Author:
7 David Young
8"""
9from __future__ import print_function
10from builtins import zip
11from builtins import object
12import sys
13import os
14import khufu
15from dryxPyramid.models.models_base import base_model
17class models_transients_comments_get(base_model):
18 """
19 The worker class for the models_transients_comments_get module
21 **Key Arguments**
23 - ``log`` -- logger
24 - ``request`` -- the pyramid request
25 - ``elementId`` -- the specific element id requests (or False)
27 """
29 def __init__(self, log, request, elementId=False, search=False):
30 super().__init__(log, request, elementId, search)
31 self.resourceName = "transients_comments"
32 self._set_default_parameters()
33 log.debug(
34 "instansiating a new 'models_transients_comments_get' object")
35 return None
37 def get(self):
38 """execute the get method on the models_transients_comments_get object
40 **Return**
42 - ``responseContent`` -- the reponse to send to the browser
44 """
45 self.log.debug('starting the ``get`` method')
46 elementId = self.elementId
48 if elementId:
49 whereClause = " and pesstoObjectsID = %(elementId)s" % locals()
50 else:
51 whereClause = ""
53 sqlQuery = """
54 select * from pesstoObjectsComments where 1=1 %(whereClause)s order by dateCreated desc limit 10
55 """ % locals()
57 objectCommentsTmp = self.request.db.execute(sqlQuery).fetchall()
58 objectComments = []
59 objectComments[:] = [dict(list(zip(list(row.keys()), row)))
60 for row in objectCommentsTmp]
62 print(objectComments)
64 self.log.debug('completed the ``get`` method')
65 return objectComments
67 # xt-class-method