What is the exact error?

I noticed you're using @view_config on the blog_view that isn't working,
with only a renderer argument. This makes me think that you might believe
that code will do the same as render_to_response(..) in your pages_view.

In fact, @view_config is a different way of doing config.add_view that
requires you to use config.scan(). I'd suggest doing a little bit more
reading on the difference between "config.add_view()" and "@view_config"
because they both accomplish the same thing and aren't intended to be used
together on the same view.

Michael


On Sat, Mar 12, 2011 at 7:09 AM, AwaisMuzaffar <[email protected]>wrote:

> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-devel?hl=en.
>
>

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

Reply via email to