Пример #1
0
    def get_user_setting(self, sid):
        """Returns tuple of (value, authenticated).  

        Value is always True or None.  This will work with Genshi template
        checkbox logic.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute(
            """
            SELECT value, authenticated
              FROM session_attribute
             WHERE sid=%s
               AND name=%s
        """, (sid, self._attr_name()))
        row = cursor.fetchone()
        if row:
            dists, v = decode(row[0])
            value = istrue(v)
            authenticated = istrue(row[1])
        else:
            dists = self.default['dists']
            value = istrue(self.default['value'])
            authenticated = False

        # We use None here so that Genshi templates check their checkboxes
        # properly and without confusion.
        return (dists, value and True or None, authenticated)
Пример #2
0
    def get_user_setting(self, sid):
        """Returns tuple of (value, authenticated).  

        Value is always True or None.  This will work with Genshi template
        checkbox logic.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("""
            SELECT value, authenticated
              FROM session_attribute
             WHERE sid=%s
               AND name=%s
        """, (sid, self._attr_name()))
        row = cursor.fetchone()
        if row:
            dists, v = decode(row[0])
            value = istrue(v)
            authenticated = istrue(row[1])
        else:
            dists = self.default['dists']
            value = istrue(self.default['value'])
            authenticated = False

        # We use None here so that Genshi templates check their checkboxes 
        # properly and without confusion.
        return (dists, value and True or None, authenticated)
Пример #3
0
 def set_user_setting(self, session, value=None, dists=('email',), save=True):
     """Sets session attribute to 1 or 0."""
     if istrue(value):
         session[self._attr_name()] = encode(dists, '1')
     else:
         session[self._attr_name()] = encode(dists, '0')
     if save:
         session.save()
Пример #4
0
    def get_subscriptions(self):
        """Generates tuples of (distributor, sid, authenticated, email).  

        Tuples are suitable for yielding from IAnnouncementSubscriber's 
        subscriptions method.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("""
            SELECT sid, authenticated, value
              FROM session_attribute
             WHERE name=%s
        """, (self._attr_name(),))
        for result in cursor.fetchall():
            dists, val = decode(result[2])
            for dist in dists:
                if istrue(val):
                    authenticated = istrue(result[1])
                    yield  (dist, result[0], authenticated, None)
Пример #5
0
    def get_subscriptions(self):
        """Generates tuples of (distributor, sid, authenticated, email).  

        Tuples are suitable for yielding from IAnnouncementSubscriber's 
        subscriptions method.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute(
            """
            SELECT sid, authenticated, value
              FROM session_attribute
             WHERE name=%s
        """, (self._attr_name(), ))
        for result in cursor.fetchall():
            dists, val = decode(result[2])
            for dist in dists:
                if istrue(val):
                    authenticated = istrue(result[1])
                    yield (dist, result[0], authenticated, None)
Пример #6
0
 def set_user_setting(self,
                      session,
                      value=None,
                      dists=('email', ),
                      save=True):
     """Sets session attribute to 1 or 0."""
     if istrue(value):
         session[self._attr_name()] = encode(dists, '1')
     else:
         session[self._attr_name()] = encode(dists, '0')
     if save:
         session.save()
Пример #7
0
    def get_user_setting(self, sid):
        """Returns tuple of (value, authenticated)."""
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("""
            SELECT value, authenticated
              FROM session_attribute
             WHERE sid=%s
               AND name=%s
        """, (sid, self._attr_name()))
        row = cursor.fetchone()
        if row:
            pair = decode(row[0])
            authenticated = istrue(row[1])
        else:
            pair = (self.default['dists'], self.default['value'])
            authenticated = False

        # We use None here so that Genshi templates check their checkboxes 
        # properly and without confusion.
        return pair + (authenticated,)
Пример #8
0
    def get_subscriptions(self, match):
        """Generates tuples of (distributor, sid, authenticated, email).  

        `match` should is passed the string value of the setting and should
        return true or false depending on whether the subscription matches.

        Tuples are suitable for yielding from IAnnouncementSubscriber's 
        subscriptions method.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute("""
            SELECT sid, authenticated, value
              FROM session_attribute
             WHERE name=%s
        """, (self._attr_name(),))
        for result in cursor.fetchall():
            dists, val = decode(result[2])
            for dist in dists:
                if match(dist, val):
                    authenticated = istrue(result[1])
                    yield  (dist, result[0], authenticated, None)
Пример #9
0
    def get_user_setting(self, sid):
        """Returns tuple of (value, authenticated)."""
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute(
            """
            SELECT value, authenticated
              FROM session_attribute
             WHERE sid=%s
               AND name=%s
        """, (sid, self._attr_name()))
        row = cursor.fetchone()
        if row:
            pair = decode(row[0])
            authenticated = istrue(row[1])
        else:
            pair = (self.default['dists'], self.default['value'])
            authenticated = False

        # We use None here so that Genshi templates check their checkboxes
        # properly and without confusion.
        return pair + (authenticated, )
Пример #10
0
    def get_subscriptions(self, match):
        """Generates tuples of (distributor, sid, authenticated, email).  

        `match` should is passed the string value of the setting and should
        return true or false depending on whether the subscription matches.

        Tuples are suitable for yielding from IAnnouncementSubscriber's 
        subscriptions method.
        """
        db = self.env.get_db_cnx()
        cursor = db.cursor()
        cursor.execute(
            """
            SELECT sid, authenticated, value
              FROM session_attribute
             WHERE name=%s
        """, (self._attr_name(), ))
        for result in cursor.fetchall():
            dists, val = decode(result[2])
            for dist in dists:
                if match(dist, val):
                    authenticated = istrue(result[1])
                    yield (dist, result[0], authenticated, None)
Пример #11
0
 def _map(value):
     g = re.match('^component_(.*)', value)
     if g:
         if istrue(req.args.get(value)):
             return g.groups()[0]
Пример #12
0
 def _map(value):
     g = re.match('^joinable_group_(.*)', value)
     if g:
         if istrue(req.args.get(value)):
             return g.groups()[0]
Пример #13
0
 def _map(value):
     g = re.match("^component_(.*)", value)
     if g:
         if istrue(req.args.get(value)):
             return g.groups()[0]
Пример #14
0
 def _map(value):
     g = re.match("^joinable_group_(.*)", value)
     if g:
         if istrue(req.args.get(value)):
             return g.groups()[0]