There is still a "bug" with the tutorial on the link Chris McDonough
provided. The tutorial requires modification of populate.py, but lists
the contents of the file models.py (twice). I'd suggest that the
second listing should be of scripts/populate.py

Following the link at the top of the page:

http://github.com/Pylons/pyramid/tree/master/docs/tutorials/wiki2/src/models/

Allowed me to grab the source to scripts/populate.py, and resolved the
same issue for me.

Cheers,
Chris

On Jan 11, 12:28 pm, Chris McDonough <[email protected]> wrote:
> On Wed, 2012-01-11 at 10:38 -0800, Łukasz wrote:
> > Hi!
>
> > Did somebody created wiki-tutorial from scratch? I need some
> > explanation, please!
>
> > In views.py there are two views defined. First one simply redirect to /
> > FrontPage:
> > @view_config(route_name='view_wiki')
> > def view_wiki(request):
> >     return HTTPFound(location = request.route_url('view_page',
> > pagename='FrontPage'))
>
> > But second view searches „FrontPage” in database, in wiki entries.
> > Because there is no ”FrontPage" entry, view goes to 404:
>
> > @view_config(route_name='view_page', renderer='templates/view.pt')
> > def view_page(request):
> >     pagename = request.matchdict['pagename']
> >     session = DBSession()
> >     page = session.query(Page).filter_by(name=pagename).first()
>
> >     # BUG HERE?: if pagename == "FrontPage" because there is no entry
> > „FrontPage” view is redirected to "404 Not Found"
> >     if page is None:
> >         return HTTPNotFound('No such page')
>
> >     def check(match):
> >         word = match.group(1)
> >         exists = session.query(Page).filter_by(name=word).all()
> >         if exists:
> >             view_url = request.route_url('view_page', pagename=word)
> >             return '<a href="%s">%s</a>' % (view_url, word)
> >         else:
> >             add_url = request.route_url('add_page', pagename=word)
> >             return '<a href="%s">%s</a>' % (add_url, word)
>
> >     content = publish_parts(page.data, writer_name='html')
> > ['html_body']
> >     content = wikiwords.sub(check, content)
> >     edit_url = request.route_url('edit_page', pagename=pagename)
> >     return dict(page=page, content=content, edit_url=edit_url,
> >                 logged_in=authenticated_userid(request))
>
> > Or I missed something?
>
> I think you may have missed:
>
> http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorial...
>
>
>
>
>
>
>
>
>
> > best
> > Ł

-- 
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