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 HTML template module for the `models_transients_element_context_post.py` resource* 

5 

6:Author: 

7 David Young 

8""" 

9from builtins import object 

10import sys 

11import os 

12import khufu 

13from fundamentals import times 

14 

15 

16class models_transients_element_context_post(object): 

17 """ 

18 The worker class for the models_transients_element_context_post module 

19 

20 **Key Arguments** 

21 

22 - ``log`` -- logger 

23 - ``request`` -- the pyramid request 

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

25 

26 """ 

27 

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 

38 

39 log.debug( 

40 "instansiating a new 'models_transients_element_context_post' object") 

41 

42 return None 

43 

44 def close(self): 

45 del self 

46 return None 

47 

48 def post(self): 

49 """execute the put method on the models_transients_element_context_post object 

50 

51 **Return** 

52 

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

54 

55 """ 

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

57 

58 transientBucketId = self.elementId 

59 

60 # variables 

61 now = times.get_now_sql_datetime() 

62 author = self.request.authenticated_userid 

63 comment = self.request.params["sherlockMatchComment"] 

64 

65 comment = comment.replace( 

66 "'", "\\'").replace('"', '\\"') 

67 

68 # # ADD THE COMMENT TO THE DATABASE 

69 sqlQuery = """ 

70 update sherlock_classifications set mismatchComment = "%(comment)s", user = "%(author)s", commentDate=now() where transient_object_id = %(transientBucketId)s; 

71 """ % locals() 

72 self.log.debug("""add comment sqlquery: `%(sqlQuery)s`""" % locals()) 

73 self.request.db.execute(sqlQuery) 

74 self.request.db.commit() 

75 

76 responseContent = "%(author)s added the some verification info for the sherlock classification to transient #%(transientBucketId)s in the marshall<BR><BR>" % locals( 

77 ) 

78 

79 logEntry = "contextual classifier transient-host mismatch reported by %(author)s" % locals( 

80 ) 

81 sqlQuery = u"""insert ignore into transients_history_logs ( 

82 transientBucketId, 

83 dateCreated, 

84 log 

85 ) 

86 VALUES ( 

87 %s, 

88 "%s", 

89 "%s" 

90 )""" % (transientBucketId, now, logEntry) 

91 self.request.db.execute(sqlQuery) 

92 self.request.db.commit() 

93 

94 self.log.debug('completed the ``put`` method') 

95 return responseContent 

96 

97 # xt-class-method