Example #1
0
 def do_update(db):
     attrs = SubscriptionAttribute.find_by_sid_class_and_target(
         self.env, req.session.sid, req.session.authenticated, klass,
         name)
     if attrs:
         SubscriptionAttribute.delete_by_sid_class_and_target(
             self.env, req.session.sid, req.session.authenticated,
             klass, name)
         req.session['_blog_watch_message_'] = \
             _('You are no longer watching this blog post.')
     else:
         SubscriptionAttribute.add(self.env, req.session.sid,
                                   req.session.authenticated, klass,
                                   'blog', (name, ))
         req.session['_blog_watch_message_'] = \
                 _('You are now watching this blog post.')
Example #2
0
 def do_update(db):
     attrs = SubscriptionAttribute.find_by_sid_class_and_target(
         self.env, req.session.sid, req.session.authenticated,
         klass, name)
     if attrs:
         SubscriptionAttribute.delete_by_sid_class_and_target(
             self.env, req.session.sid, req.session.authenticated,
             klass, name)
         req.session['_blog_watch_message_'] = \
             _('You are no longer watching this blog post.')
     else:
         SubscriptionAttribute.add(
             self.env, req.session.sid, req.session.authenticated,
             klass, 'blog', (name,))
         req.session['_blog_watch_message_'] = \
                 _('You are now watching this blog post.')
Example #3
0
    def process_request(self, req):
        klass = self.__class__.__name__

        m = re.match(r'^/blog_watch/(.*)', req.path_info)
        (name,) = m.groups()

        with self.env.db_transaction:
            attrs = SubscriptionAttribute.find_by_sid_class_and_target(
                self.env, req.session.sid, req.session.authenticated,
                klass, name)
            if attrs:
                SubscriptionAttribute.delete_by_sid_class_and_target(
                    self.env, req.session.sid, req.session.authenticated,
                    klass, name)
                req.session['_blog_watch_message_'] = \
                    _("You are no longer watching this blog post.")
            else:
                SubscriptionAttribute.add(
                    self.env, req.session.sid, req.session.authenticated,
                    klass, 'blog', (name,))
                req.session['_blog_watch_message_'] = \
                    _("You are now watching this blog post.")

        req.redirect(req.href.blog(name))