Hi Guys,

I have the following code for the view:

def pages_view(request):
    path = request.path.split('/')[1]
    dbsession = DBSession()
    page = dbsession.query(PagesTable).from_statement(
        'SELECT * FROM pages WHERE
path=:page_path').params(page_path=path).first()
    pages_dir = os.getcwd() + '/myblog/templates/pages/'
    one = 'hello'
    if page:
        if path == '':
             return render_to_response('myblog:templates/pages/
home.mak',
                {'page':page, 'one':one}, request=request)
        elif os.path.isfile(pages_dir + path + '.mak'):
            return render_to_response('myblog:templates/pages/
%s.mak'%path,
                {'page':page}, request=request)
        else:
            return render_to_response('myblog:templates/pages/
index.mak',
                {'page':page}, request=request)
    raise NotFound()

Basically, it checks if a page exists in the table. If it does it
renders a template according to the path name, or if there is no such
template it just renders a default template.

The next part I want to do is create a seperate view function for my
'blog' page, with some logic for this page.

I've tried the following example, but it throws an undefined error
when when I load the page:

@view_config(renderer='myblog:templates/pages/my-blog.mak')
def blog_view(request):
    one = 'Hello World'
    return {'one':one}

I do apologise for such basic questions. Any insight given will be
greatly appreciated.

Kind Regards,
Awais M.



-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to