예제 #1
0
    def reply(self, content, **argv):
        if not self._topicID:
            return Exception('topic-not-loaded')

        if not _isSectionID(self._parentID):
            # now disable replying to a reply
            return Exception('not-allowed-replying-to-a-reply')

        topicID = _getTopicID(self._topicID, '', content)
        posttime = int(time.time())
        try:
            if argv.has_key('time'):
                posttime = int(argv['time'])
        except:
            pass

        self._sqldb.insert(
            'topics',
            {
                'tid': topicID,  # of this new reply
                'pid': self._topicID,  # to which this new reply belongs
                'title': '',
                'content': content.encode('hex'),
                'sid': self._sectionID,
                'time': posttime,
            })

        return topicID
예제 #2
0
    def reply(self, content, **argv):
        if not self._topicID:
            return Exception('topic-not-loaded')

        if not _isSectionID(self._parentID):
            # now disable replying to a reply
            return Exception('not-allowed-replying-to-a-reply')

        topicID = _getTopicID(self._topicID, '', content)
        posttime = int(time.time())
        try:
            if argv.has_key('time'):
                posttime = int(argv['time'])
        except:
            pass

        self._sqldb.insert(
            'topics', 
            {
                'tid': topicID,         # of this new reply
                'pid': self._topicID,   # to which this new reply belongs
                'title': '',
                'content': content.encode('hex'),
                'sid': self._sectionID,
                'time': posttime,
            }
        )

        return topicID
예제 #3
0
    def create(self, title, content, **argv):
        topicID = _getTopicID(self._sectionID, title, content)

        posttime = int(time.time())
        try:
            if argv.has_key('time'):
                posttime = int(argv['time'])
        except:
            pass

        self._sqldb.insert(
            'topics',
            {
                'tid': topicID,  # of this new topic
                'pid': self._sectionID,  # under which section this topic is
                'title': title.encode('hex'),
                'content': content.encode('hex'),
                'sid': self._sectionID,  # cache section, also for replys
                'time': posttime,
            })

        # inform the update of this section
        # TODO

        result = self.load(topicID)
        if True != result:
            return Exception('topic-creation-failure')
        return topicID
예제 #4
0
    def create(self, title, content, **argv):
        topicID = _getTopicID(self._sectionID, title, content)

        posttime = int(time.time())
        try:
            if argv.has_key('time'):
                posttime = int(argv['time'])
        except:
            pass

        self._sqldb.insert(
            'topics', 
            {
                'tid': topicID,         # of this new topic
                'pid': self._sectionID, # under which section this topic is
                'title': title.encode('hex'),
                'content': content.encode('hex'),
                'sid': self._sectionID, # cache section, also for replys
                'time': posttime,
            }
        )

        # inform the update of this section
        # TODO

        result = self.load(topicID)
        if True != result:
            return Exception('topic-creation-failure')
        return topicID