Beispiel #1
0
    def get(self, rev_id):
        context = { }

        try:
            timestamp = self.request.get('timestamp')
            
            context['content'] = views_page.render(rev_id, timestamp)

        except Exception as e:
            context['error'] = str(e)

        finally:
            if self.request.get('print'):
                self.response.write(context[self.request.get('print')])

            else:
                tools.json_response(self, context)
Beispiel #2
0
    def get(self, terms=None, tilds=None):
        context = { }

        try:
            timestamp = self.request.get('timestamp')

            state = init_state(terms, tilds, timestamp)

            results = views_page.search(**state)
            result = None if not len(results) == 1 else results[0]

            if result and result.get('rev_id'):
                state['terms_v'] = result['page_title']

                state_title = 'Page: '
                state['content'] = views_page.render(result['rev_id'], timestamp),
                state['render_url'] = uri_for('Render', rev_id=result['rev_id'], timestamp=timestamp or '')

            elif result:
                state_title = 'Page Missing: '
                state['content'] = tools.render_to_string('page_non_existent.html', dict({'result' : result}, **state))

            elif terms:
                state_title = 'Results: '
                state['content'] = tools.render_to_string('page_results.html', dict({'results' : results}, **state))

            else:
                state_title = 'Home'
                state['content'] = tools.render_to_string('page_empty.html')

            context.update({
                'state'         : state,
                'state_title'   : 'Tilde - ' + state_title + str(state['terms_v']) + str(state['tilds_v']),
                'state_url'     : uri_for('Base', terms=state['terms_v'] or '', tilds=state['tilds_v'])
            })

        except Exception as e:
            context['error'] = str(e)

        finally:
            if self.request.get('print'):
                self.response.write(context['state'][self.request.get('print')])

            else:
                tools.json_response(self, context)