Changeset 668


Ignore:
Timestamp:
05/12/15 17:44:52 (6 years ago)
Author:
bas
Message:

suppoer discussionplugin 0.9dev, older versions are noi supported anymore, see #365

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r666 r668  
     12.9.X:
     2   * email2trac now supports discussionplugin v0.9dev. The older vcersions are not supported anymore, closes #365
     3    Author: ???
     4    Applied by: Bas van der Vlies
     5
    162.8.9:
    27   * Added a new parameter only save email and removed some obsolete code in ave_email_for_debug,
  • trunk/email2trac.py.in

    r666 r668  
    15441544        #
    15451545        api = self.env[DiscussionApi]
    1546         context = self._create_context(content, subject)
     1546        args = {'forum' : self.id}
     1547        context = self._create_context(api, args, content, subject)
    15471548
    15481549        ## Get forum for new topic.
    15491550        #
    1550         forum = api.get_forum(context, self.id)
     1551        forum = context.forum
    15511552
    15521553        if not forum:
     
    15651566        #
    15661567        self._add_topic(api, context, topic)
    1567         self.db.commit()
    15681568
    15691569    def discussion_topic_reply(self, content, subject):
     
    15791579        #
    15801580        api = self.env[DiscussionApi]
    1581         context = self._create_context(content, subject)
     1581        args = {'topic' : self.id}
     1582        context = self._create_context(api, args, content, subject)
    15821583
    15831584        ## Get replied topic.
    15841585        #
    1585         topic = api.get_topic(context, self.id)
     1586        topic = context.topic
    15861587
    15871588        if not topic:
     
    16001601        #
    16011602        self._add_message(api, context, message)
    1602         self.db.commit()
    16031603
    16041604    def discussion_message_reply(self, content, subject):
     
    16141614        #
    16151615        api = self.env[DiscussionApi]
    1616         context = self._create_context(content, subject)
     1616        args = {'message' : self.id}
     1617        context = self._create_context(api, args, content, subject)
    16171618
    16181619        ## Get replied message.
    16191620        #
    1620         message = api.get_message(context, self.id)
     1621        message = context.message
    16211622
    16221623        if not message:
     
    16351636        #
    16361637        self._add_message(api, context, message)
    1637         self.db.commit()
    1638 
    1639     def _create_context(self, content, subject):
     1638
     1639    def _create_context(self, api, args, content, subject):
    16401640
    16411641        ## Import modules.
     
    16431643        from trac.mimeview import Context
    16441644        from trac.web.api import Request
     1645        from trac.web.session import Session
    16451646        from trac.perm import PermissionCache
    16461647
     
    16681669        req.perm = PermissionCache(self.env, self.author)
    16691670        req.locale = None
     1671        req.args = args
     1672        req.session = Session(env, req)
    16701673
    16711674        ## Create and return context.
     
    16731676        context = Context.from_request(req)
    16741677        context.realm = 'discussion-email2trac'
    1675         context.cursor = self.db.cursor()
     1678        context.db = self.env.get_db_cnx()
    16761679        context.content = content
    16771680        context.subject = subject
     
    16821685        context.content_parts = self.unique_attachment_names(
    16831686          context.content_parts)
     1687
     1688        api._prepare_context(context)
    16841689
    16851690        return context
     
    17001705        ## Add a new topic.
    17011706        #
    1702         api.add_topic(context, topic)
     1707        new_topic_id = api.add_topic(context, topic)
    17031708
    17041709        ## Get inserted topic with new ID.
    17051710        #
    1706         topic = api.get_topic_by_time(context, topic['time'])
     1711        topic = api.get_topic(context, new_topic_id)
    17071712
    17081713        ## Attach attachments.
     
    17311736        ## Add message.
    17321737        #
    1733         api.add_message(context, message)
     1738        new_msg_id = api.add_message(context, message)
    17341739
    17351740        ## Get inserted message with new ID.
    17361741        #
    1737         message = api.get_message_by_time(context, message['time'])
     1742        message = api.get_message(context, new_msg_id)
    17381743
    17391744        ## Attach attachments.
Note: See TracChangeset for help on using the changeset viewer.