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_element_comments_post.py` resource*
6:Author:
7 David Young
8"""
9from builtins import object
10import sys
11import os
12import khufu
13from fundamentals import times
16class models_transients_element_comments_post(object):
17 """
18 The worker class for the models_transients_element_comments_post module
20 **Key Arguments**
22 - ``log`` -- logger
23 - ``request`` -- the pyramid request
24 - ``elementId`` -- the specific element id requests (or False)
26 """
28 def __init__(
29 self,
30 log,
31 request,
32 elementId=False
33 ):
34 self.log = log
35 self.request = request
36 self.elementId = elementId
37 # xt-self-arg-tmpx
39 log.debug(
40 "instansiating a new 'models_transients_element_comments_post' object")
42 return None
44 def close(self):
45 del self
46 return None
48 def post(self):
49 """execute the put method on the models_transients_element_comments_post object
51 **Return**
53 - ``responseContent`` -- the reponse to send to the browser
55 """
56 self.log.debug('starting the ``put`` method')
58 transientBucketId = self.elementId
60 # variables
61 now = times.get_now_sql_datetime()
62 author = self.request.authenticated_userid
63 comment = self.request.params["comment"]
65 comment = comment.replace(
66 "'", "\\'").replace('"', '\\"')
68 # add the comment to the database
69 sqlQuery = """
70 INSERT INTO pesstoObjectsComments (pesstoObjectsId,commentAuthor,comment,dateCreated,dateLastModified) VALUES(%(transientBucketId)s,"%(author)s","%(comment)s","%(now)s","%(now)s");
71 """ % locals()
72 self.log.debug("""add comment sqlquery: `%(sqlQuery)s`""" % locals())
73 self.request.db.execute(sqlQuery)
74 self.request.db.commit()
76 responseContent = "%(author)s added the comment:<blockquote>%(comment)s</blockquote>to transient #%(transientBucketId)s in the marshall<BR><BR>" % locals(
77 )
79 self.log.debug('completed the ``put`` method')
80 return responseContent
82 # xt-class-method