Exemplo n.º 1
0
    def render_page(self, template_file_name, content_template_values, template_path=None):
        """This re-renders the full page with the specified template."""
        user = self.get_user()

        template_values = {
            'URL'  : URL,
            'user' : user
        }
        merged_values = dict(template_values)
        merged_values.update(content_template_values)
        
        path = os.path.join('templates/', template_file_name)
        
        app_path = self.get_app_path()

        if template_path != None:
            logging.info('got template_path: %s' % template_path)
            path = os.path.join(template_path, path)
        elif app_path != None:
            path = os.path.join(app_path, path)

        # Make sure the cookie is always set.
        if user:
            set_user_cookie( self, user.uuid )

        logging.info("Rendering %s" % path )
        self.response.headers.add_header('P3P', P3P_HEADER)
        return render(path, merged_values)
Exemplo n.º 2
0
    def post( self ):
        user = self.get_user()

        if not user:
            first_name  = self.request.get( 'firstName' )
            last_name   = self.request.get( 'lastName' )
            email       = self.request.get( 'email' )
            
            user        = User.create( first_name, last_name, email )

            # Cache the User
            self.db_user = user

            # Have to do this here to avoid a circular reference
            set_user_cookie( self, user.uuid )
        
        self.response.headers['Content-Type'] = "application/json"
        self.response.out.write( json.dumps( { 'uuid' : user.uuid,
                                               'img'  : user.img } ) )