@@ -89,25 +89,42 @@ def update_comment(self, sketch, results, current_date, log_entry, openFailFlag,
89
89
def handle_library_comment (self , library , current_date , log ):
90
90
url = '/library/' + library
91
91
identifier = 'ident:' + url
92
+
92
93
if url not in log :
93
94
log [url ] = {}
94
95
try :
95
96
log [url ]['comment' ] = False
97
+
98
+ """ Returns a Paginator object that matches the desired criteria:
99
+ `self.disqus.api.threads.list`: Returns a list containg all urls in which Disqus loaded.
100
+ `forum`: Looks up a forum by short name.
101
+ `thread`: Looks up a thread by ID BUT you may pass us the 'ident' query type instead of
102
+ an ID by including 'forum'. Filters results returned from `self.disqus.api.threads.list`
103
+ and returns only those which match `forum` and `thread`.
104
+ IMPORTANT: If `thread` is not found, all threads are returned!!!
105
+ """
96
106
paginator = disqusapi .Paginator (self .disqus .api .threads .list ,
97
107
forum = FORUM ,
98
- thread = identifier , method = 'GET' )
108
+ thread = identifier )
99
109
if paginator :
100
110
comment_updated = False
101
111
new_message = self .messages ['library' ].replace ('TEST_DATE' , current_date )
102
- for page in paginator :
103
- post_id , existing_message = self .get_posts (page ['id' ])
112
+
113
+ for thread in paginator :
114
+
115
+ # Check if library has already a comment.
116
+ post_id , existing_message = self .get_posts (thread ['id' ])
117
+
118
+ #If library already has a comment, update it.
104
119
if post_id and existing_message :
105
120
log [url ]['comment' ] = self .update_post (post_id , new_message )
106
121
comment_updated = True
107
122
break
108
123
124
+ #If library doesn't have a comment, create it.
109
125
if not comment_updated :
110
126
log [url ]['comment' ] = self .create_post (identifier , new_message )
127
+
111
128
except Exception as error :
112
129
print 'Error:' , error
113
130
log [url ]['comment' ] = False
0 commit comments