Example #1
0
    def __call__(self, environ, start_response):

        facebook_uid = self.facebook_uid_from_cookie(environ)

        if facebook_uid:

            my_charts = Chart.my_charts(self.dbconn, facebook_uid)

            start_response('200 OK',
                           [('Content-Type', 'text/html; charset=utf-8')])

            t = self.templates.get_template('my-charts.html')

            return [
                t.render(app_id=self.config_wrapper.app_id,
                         my_charts=my_charts)
            ]

        else:

            start_response('200 OK',
                           [('Content-Type', 'text/html; charset=utf-8')])

            t = self.templates.get_template('splashpage.html')

            return [t.render(app_id=self.config_wrapper.app_id)]
Example #2
0
    def __call__(self, environ, start_response):

        raw_post_data = environ['wsgi.input'].read(
            int(environ['CONTENT_LENGTH']))

        parsed_post_data = urlparse.parse_qs(raw_post_data)

        facebook_uid = self.facebook_uid_from_cookie(environ)

        try:

            chart = Chart.from_parsed_post_data(self.dbconn, facebook_uid,
                                                parsed_post_data)

            redirect_target = (
                '%s/chart/%s' %
                (self.config_wrapper.parsed_config['server']['host'],
                 chart.chart_id))

            start_response('302 FOUND', [('Location', redirect_target)])

            return []

        except ValueError, ex:

            start_response('200 OK',
                           [('Content-Type', 'text/html; charset=utf-8')])

            message = ex.args[0]

            t = self.templates.get_template('new-chart-error.html')

            return [t.render(message=ex.args[0])]
Example #3
0
    def __call__(self, environ, start_response):

        facebook_uid = self.facebook_uid_from_cookie(environ)

        if facebook_uid:

            my_charts = Chart.my_charts(self.dbconn, facebook_uid)

            start_response(
                '200 OK',
                [('Content-Type', 'text/html; charset=utf-8')])

            t = self.templates.get_template('my-charts.html')

            return [t.render(
                app_id=self.config_wrapper.app_id,
                my_charts=my_charts)]

        else:

            start_response(
                '200 OK',
                [('Content-Type', 'text/html; charset=utf-8')])

            t = self.templates.get_template('splashpage.html')

            return [t.render(
                app_id=self.config_wrapper.app_id)]
Example #4
0
    def __call__(self, environ, start_response):

        chart_id = self.extract_chart_id(environ['PATH_INFO'])

        chart = Chart.by_primary_key(self.dbconn, chart_id)

        start_response('200 OK',
                       [('Content-Type', 'text/html; charset=utf-8')])

        t = self.templates.get_template('chart.html')

        return [t.render(chart=chart, app_id=self.config_wrapper.app_id)]
Example #5
0
    def __call__(self, environ, start_response):

        chart_id = self.extract_chart_id(environ['PATH_INFO'])

        chart = Chart.by_primary_key(self.dbconn, chart_id)

        start_response(
            '200 OK',
            [('Content-Type', 'text/html; charset=utf-8')])

        t = self.templates.get_template('chart.html')

        return [t.render(chart=chart,
            app_id=self.config_wrapper.app_id)]
Example #6
0
    def __call__(self, environ, start_response):

        chart_id = self.extract_chart_id(environ['PATH_INFO'])

        chart = Chart.by_primary_key(self.dbconn, chart_id)

        action = self.extract_action(environ['PATH_INFO'])

        action(chart, self.dbconn)

        redirect_target = (
            '%s/chart/%d' %
            (self.config_wrapper.parsed_config['server']['host'], chart_id))

        start_response('302 FOUND', [('Location', redirect_target)])

        return []
Example #7
0
    def __call__(self, environ, start_response):

        chart_id = self.extract_chart_id(environ['PATH_INFO'])

        chart = Chart.by_primary_key(self.dbconn, chart_id)

        action = self.extract_action(environ['PATH_INFO'])

        action(chart, self.dbconn)

        redirect_target = (
            '%s/chart/%d'
            % (
                self.config_wrapper.parsed_config['server']['host'],
                chart_id))

        start_response(
        '302 FOUND',
        [('Location', redirect_target)])

        return []
Example #8
0
    def __call__(self, environ, start_response):

        raw_post_data = environ['wsgi.input'].read(
            int(environ['CONTENT_LENGTH']))

        parsed_post_data = urlparse.parse_qs(raw_post_data)

        facebook_uid = self.facebook_uid_from_cookie(environ)

        try:

            chart = Chart.from_parsed_post_data(
                self.dbconn, facebook_uid, parsed_post_data)

            redirect_target = (
                '%s/chart/%s'
                % (self.config_wrapper.parsed_config['server']['host'],
                    chart.chart_id))

            start_response(
            '302 FOUND',
            [('Location', redirect_target)])

            return []

        except ValueError, ex:

            start_response(
                '200 OK',
                [('Content-Type', 'text/html; charset=utf-8')])

            message = ex.args[0]

            t = self.templates.get_template('new-chart-error.html')

            return [t.render(message=ex.args[0])]