Esempio n. 1
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            "check if user should have totals calculated"
            if ('format' in environ['pylons.routes_dict'] and
                    environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        if (self.identity is not None and 'user' in self.identity
                and environ['pylons.routes_dict']['controller'] != 'error'
                and check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()

                tzinfo = self.identity['user'].timezone or UTC
                c.tzinfo = make_tz(tzinfo)
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
Esempio n. 2
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            if ('format' in environ['pylons.routes_dict'] and
                    environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        # raise ValueError(self.identity)
        # if 'baruwa.auth.plugin' in self.identity:
        #     session['baruwa.auth.plugin'] = self.identity['baruwa.auth.plugin']
        #     session.save()
        if (not self.identity is None and 'user' in self.identity
                and environ['pylons.routes_dict']['controller'] != 'error'
                and check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
Esempio n. 3
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            "check if user should have totals calculated"
            if ('format' in environ['pylons.routes_dict'] and
                environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        if (self.identity is not None and 'user' in self.identity and
            environ['pylons.routes_dict']['controller'] != 'error' and
            check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()

                tzinfo = self.identity['user'].timezone or UTC
                c.tzinfo = make_tz(tzinfo)
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()
Esempio n. 4
0
    def __call__(self, environ, start_response):
        """Invoke the Controller"""
        def check_url():
            if ('format' in environ['pylons.routes_dict'] and
                environ['pylons.routes_dict']['format'] in ['csv', 'pdf']):
                return False
            if environ['PATH_INFO'] == '/jsi18n.js':
                return False
            return True

        self.identity = environ.get('repoze.who.identity')
        # raise ValueError(self.identity)
        # if 'baruwa.auth.plugin' in self.identity:
        #     session['baruwa.auth.plugin'] = self.identity['baruwa.auth.plugin']
        #     session.save()
        if (not self.identity is None and 'user' in self.identity and
            environ['pylons.routes_dict']['controller'] != 'error' and
            check_url()):

            if self.identity['user']:
                totals = DailyTotals(Session, self.identity['user'])
                mailq = MailQueue(Session, self.identity['user'])
                c.baruwa_totals = totals.get()
                c.baruwa_inbound = mailq.get(1)[0]
                c.baruwa_outbound = mailq.get(2)[0]
                if self.identity['user'].is_admin:
                    c.baruwa_status = cluster_status()
        try:
            return WSGIController.__call__(self, environ, start_response)
        finally:
            Session.remove()