Example #1
0
 def writeHtml(self, doc_id, content):
     "Set the content of article. The file is html."
     try:
         #Fixme: I couldn't convert content to unicode.
         fd = File(str(doc_id), 'a', 'wb')
         fd.write(content)
         fd.close()
     
     except Exception as err:
         msg = "We couldn't write %s" % doc_id
         loggero().error('Article.write %s' % msg)
         loggero().error(repr(err))
Example #2
0
    def set(self, doc_id):
        # Load json
        self.doc_id = str(doc_id)
        try:
            fd = File(self.doc_id, 'c', 'r')
            content = fd.read()
            fd.close()
        except IOError:
            # There is no comment file.
            content = '{}'
        try:
            json_load = json.loads(content)
        except ValueError:
            # We get empty content.
            json_load = {}

        # Set json
        self.setFromDict(json_load)
Example #3
0
 def save(self):
     json_dump = json.dumps(self.json)
     fd = File('', 'i', 'w')
     fd.write(json_dump)
     fd.close()
Example #4
0
 def save(self):
     json_dump = json.dumps(self.json)
     fd = File(self.doc_id, 'c', 'w')
     fd.write(json_dump)
     fd.close()