can't agree with you any more. this should be done in the section of templates . just for this case. c.titles = [page.title for page in model.Page.select()] was choose in 8.4. so the code c.titles = model.Page.select() doesn't work here(at least on my PC). for they share the same templates.
On 5月2日, 下午9时39分, Graham Higgins <[EMAIL PROTECTED]> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > On 2 May 2007, at 13:01, Aldarion wrote: > > > > > here > >http://pylonshq.com/docs/0.9.5/quick_wiki.html#delete > > in def delete(self): > > the line > > c.titles = model.Page.select() > > should be > > c.titles = [page.title for page in model.Page.select()] > > isn't it? > > That's a fair point and it is one way of approaching the task of > compiling a list of titles. > > However, it is arguable that this is a data presentation task which > is better done in the template, leaving your controller code to > concentrate on the core tasks. > > The quick_wiki tutorial chooses this second tactic and uses template > processing ... > > If you take a look at the section on templates [1] in the tutorial, > you will see an iterative loop in the template that is applied to the > list of Page objects (produced by the "select()" in the controller) > and it is that iterative loop which compiles the list of titles. > > Making a collection of Page objects available to the template means > that in the template you can easily add, say, a "Last Modified" value > to the page merely by accessing the Page object ---- this has the > significant advantage that it avoids having to add yet another > iterative loop to the controller code. > > The approach gives you better abstraction and more power. > > Summarising: yes but no; you /could/ do it in the controller but > that's the weaker approach. > > Cheers, > > Graham. > > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.5 (Darwin) > > iQCUAgUBRjiUoFnrWVZ7aXD1AQLMXgP3YyhlZQRrL5I9dCY+h88QzdgdJTR+ZuM7 > HMB1cDlGW7usLuHlsgbpzO3q34GvsWBNmMwLVU01ax34oT1mD6A5TKDZuthn/4t/ > zTNkGbj648Rw9SMRLIxgLtFQCNa3zQyE7NAhw7jcu6a8ncsD3QYkehuBxb9wLH4H > ptFQ8WwhIg== > =ad2r > -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
